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

Admin users did not work with custom user models #4238

Merged
merged 1 commit into from
Jan 18, 2022

Conversation

softr8
Copy link
Contributor

@softr8 softr8 commented Jan 4, 2022

Description

If Spree.user_class was other than Spree::User, it was failing
to create edit and delete url's in Admin::UsersController#index,
using CustomUser for example, it tried to generate: admin_custom_user_url
instead of using the existing admin_user_url

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have attached screenshots to this PR for visual changes (if needed)

end

before do
Spree.user_class = 'UserModel'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should do an after block here too to make sure subsequent tests are using the original User.

@softr8 softr8 force-pushed the fix-admin-users branch 2 times, most recently from 893a282 to 9370d04 Compare January 5, 2022 15:28
Comment on lines 70 to 75
Spree.user_class = 'UserModel'
UserModel.create(email: "a@solidus.io")
example.run
Spree.user_class = 'Spree::LegacyUser'
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we take the old value of user_class and reset it later instead of hardcoding the value that we are using now? I.e.:

Suggested change
Spree.user_class = 'UserModel'
UserModel.create(email: "a@solidus.io")
example.run
Spree.user_class = 'Spree::LegacyUser'
end
actual_user_class = Spree.user_class
Spree.user_class = 'UserModel'
UserModel.create(email: "a@solidus.io")
example.run
Spree.user_class = actual_user_class
end

@softr8 softr8 force-pushed the fix-admin-users branch 3 times, most recently from 8b7c9d8 to c74f46e Compare January 11, 2022 16:44
end

around do |example|
actual_user_class = Spree.user_class
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, my fault. This should fix the CI, right?

Suggested change
actual_user_class = Spree.user_class
actual_user_class = Spree.user_class.name

If Spree.user_class was other than Spree::User, it was failing
to create edit and delete url's in Admin::UsersController#index,
using CustomUser for example, it tried to generate: admin_custom_user_url
instead of using the existing admin_user_url
Copy link
Contributor

@waiting-for-dev waiting-for-dev left a comment

Choose a reason for hiding this comment

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

Thanks!!

@waiting-for-dev waiting-for-dev merged commit 65a26af into solidusio:master Jan 18, 2022
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.

4 participants