-
-
Notifications
You must be signed in to change notification settings - Fork 729
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
Replace spree roles #13090
Replace spree roles #13090
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice clean up 🧹
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
I'm assuming that you're tracking this and will remove the unused DB tables after this has bedded down 👍
Perhaps it's not worth the effort, but I think I see opportunity to tidy up specs a little so have made some suggestions.
@@ -235,8 +235,6 @@ class GatewayWithPassword < PaymentMethod | |||
let(:user) do | |||
new_user = create(:user, email: 'enterprise@hub.com', password: 'blahblah', | |||
password_confirmation: 'blahblah', ) | |||
# for some reason unbeknown to me, this new user gets admin permissions by default. | |||
new_user.spree_roles = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's reassuring to see this is no longer necessary!
spree_put :update, id: test_user.id, user: { show_api_key_view: true } | ||
expect(response).to redirect_to spree.edit_admin_user_path(test_user) | ||
end | ||
|
||
it "re-renders the edit form if error" do | ||
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin') | ||
user.update!(admin: true) | ||
spree_put :update, id: test_user.id, user: { password: "blah", password_confirmation: "" } | ||
|
||
expect(response).to render_template :edit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 out of 4 tests require an admin user, so we could set it up as an admin user in the beginning.
In fact, the fourth test mocks the admin? method anyway..
Maybe I'll submit a commit.
Hope you don't mind me joining in! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvements!
Hey @mkllnk , Tried to access the pages: As a:
Access rights seem to work the same as before. |
What? Why?
Since we have only one super admin role, we can replace Spree::Role with a simple boolean flag on the user. This makes two database tables redundant and reduces database queries.
What should we test?
Release notes
Changelog Category (reviewers may add a label for the release notes):
The title of the pull request will be included in the release notes.
Dependencies
Documentation updates