Skip to content

Ap 602 refactor roles#46

Open
steve-sullivan wants to merge 6 commits into
mainfrom
AP-602-Refactor-Roles
Open

Ap 602 refactor roles#46
steve-sullivan wants to merge 6 commits into
mainfrom
AP-602-Refactor-Roles

Conversation

@steve-sullivan
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Member

@awilfox awilfox left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me. There are a few inline comments to resolve before merging, and I'd like to review again after those are done. (I'm a bit tired today and hope to review again tomorrow with fresh eyes after these changes are made.)

Comment on lines 87 to 89
authenticate!
@user_is_admin = current_user.role?(Role.stackpass_admin)
@user_is_admin = current_user.any_role?(Role.stackpass_admin, :framework_admin)
raise Error::ForbiddenError unless @user_is_admin
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a reason we don't use authenticate_with_role! Role.stackpass_admin, :framework_admin here? Seems well-suited for the task.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changing this one, easy change!

Comment thread spec/models/user_spec.rb Outdated
it 'returns false when the user does not have the role' do
user = User.new(uid: '12345')

allow(FrameworkUsers).to receive(:hardcoded_admin?).with('12345').and_return(false)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It doesn't look like hardcoded_admin? exists any more - should this still be in the test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These other two opened up a bit of a can-o-worms. Updating these and a couple of other specs...wrestling with them now.

Comment thread spec/models/user_spec.rb Outdated
it 'returns false when the user has none of the requested roles' do
user = User.new(uid: '12345')

allow(FrameworkUsers).to receive(:hardcoded_admin?).with('12345').and_return(false)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As above.

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.

2 participants