Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password change logout #2850

Merged

Conversation

Matt-Yorkley
Copy link
Contributor

What? Why?

Closes #2848

Adjusts a config setting so that users are not logged out when updating their password.

What should we test?

Users can change password via /account page without being logged out.

Release notes

Users will not be logged out whilst changing their password.

Changelog Category: Changed

Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but the spec doesn't pass. Can you have another look?

@Matt-Yorkley Matt-Yorkley force-pushed the password_change_logout branch from 57eb5dc to 55411af Compare October 9, 2018 09:08
@@ -27,5 +31,18 @@
click_link I18n.t('spree.users.show.tabs.settings')
expect(page).to have_content I18n.t('spree.users.show.unconfirmed_email', unconfirmed_email: '[email protected]')
end

it "allows the user to change their password" do
allow(Spree::Auth::Config).to receive(:[]).with(:signout_after_password_change).and_return(false)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkllnk I've added this to make the spec work, as the test environment doesn't pick up the value set in the spree initializer. Do you think this is ok, or should I try to set that config variable globally in the test environment instead? I'm wondering if it might interfere with other specs or changes to factories if it's set globally...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the way IMO. Changes to global state in tests => 💥

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that changes to the global state are not good in tests in general. And I find this solution okay, but I see a problem in the fact that the logic is different for production and testing here. We have to add this line to the test case to make it behave the same way. That's basically code duplication in a very hidden place. Imagine we had to define the checkout state machine in the same spec that verifies that it's correct. It's not really testing the code used in production then.

@@ -27,5 +31,18 @@
click_link I18n.t('spree.users.show.tabs.settings')
expect(page).to have_content I18n.t('spree.users.show.unconfirmed_email', unconfirmed_email: '[email protected]')
end

it "allows the user to change their password" do
allow(Spree::Auth::Config).to receive(:[]).with(:signout_after_password_change).and_return(false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that changes to the global state are not good in tests in general. And I find this solution okay, but I see a problem in the fact that the logic is different for production and testing here. We have to add this line to the test case to make it behave the same way. That's basically code duplication in a very hidden place. Imagine we had to define the checkout state machine in the same spec that verifies that it's correct. It's not really testing the code used in production then.

@Matt-Yorkley
Copy link
Contributor Author

I agree @mkllnk that changing the settings for the production environment but not for tests doesn't seem like a great idea. I've switched to setting it in the global test config, and all the specs are green, so I guess it's ok.

@sauloperez are you happy with that? 4760ebb

@sauloperez
Copy link
Contributor

Staged on https://staging.katuma.org/

@myriamboure
Copy link
Contributor

myriamboure commented Oct 16, 2018

testing notes: https://docs.google.com/document/d/1gtzQWewyiLawJEyyH85xUSNQHNHcAitVvLPL4lu63qQ/edit?usp=sharing

@Matt-Yorkley i randomly did another test as change password was affected I tested the "forgot password" process and it seems that PR is breaking it, the email recovery email is not sent. See notes. I tested on current French production (on v1.21) and it is working so it feels like it can be connected to that PR... back to in dev then for now.

Precision: I did create a new user so I received correctly other confirmation message so it doesn't seem related to Katuma staging setup.

@myriamboure myriamboure removed their assignment Oct 16, 2018
@Matt-Yorkley Matt-Yorkley added the pr-staged-uk staging.openfoodnetwork.org.uk label Oct 23, 2018
@Matt-Yorkley
Copy link
Contributor Author

Matt-Yorkley commented Oct 23, 2018

@myriamboure I've just put this up on UK staging, and reset password emails are working fine with this PR. I'll leave it up if you want to re-test it.

@RachL RachL self-assigned this Oct 24, 2018
@RachL
Copy link
Contributor

RachL commented Oct 24, 2018

I've retested and everything is indeed fine !

I've updated @myriamboure testing notes:
https://docs.google.com/document/d/1gtzQWewyiLawJEyyH85xUSNQHNHcAitVvLPL4lu63qQ/edit#

@RachL RachL removed the pr-staged-uk staging.openfoodnetwork.org.uk label Oct 24, 2018
@sauloperez sauloperez merged commit ce93c52 into openfoodfoundation:master Oct 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants