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

672 roles are no longer in a hierarchy #681

Merged
merged 11 commits into from
Jun 2, 2018
Merged

Conversation

aloeser
Copy link
Contributor

@aloeser aloeser commented Aug 9, 2017

all roles are separate, abilities are not inherited between roles
the user has exactly one role

@bjrne bjrne temporarily deployed to workshopportal-pr-681 August 9, 2017 17:20 Inactive
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling b0f2d61 on 672_refactor_role_system into 7bfac11 on dev.

Copy link
Collaborator

@annkatrinkuessner annkatrinkuessner 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

@@ -38,7 +38,7 @@ class User < ActiveRecord::Base
def role?(base_role)
return false unless role

ROLES.index(base_role) <= ROLES.index(role.to_sym)
ROLES.index(base_role) == ROLES.index(role.to_sym)
Copy link
Member

Choose a reason for hiding this comment

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

This looks like it could be simplified to base_role.to_sym == role.to_sym. The ROLES variable could either be completely removed or instead used to verify that base_role is valid [PSEUDOCODE] unless base_role is part of ROLES throw some error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do we want to deal with invalid roles? It is a getter function, so we cannot get into an invalid state with an invalid role given. With an invalid role it will always return false (which is correct), so we dont actually have a "real" error.
However, throwing an error might make it easier to find bugs

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the explicit (error) version I think. Shouldn't happen too much and the log would be waaaay more helpful then.

@bjrne
Copy link
Collaborator

bjrne commented Aug 9, 2017

@aloeser You could maybe create an issue for the removal of the manage ability and link it here :)

Update: see #706

@bjrne bjrne temporarily deployed to workshopportal-pr-681 August 10, 2017 09:57 Inactive
@coveralls
Copy link

coveralls commented Aug 10, 2017

Coverage Status

Coverage decreased (-0.09%) to 68.931% when pulling fc8a52c on 672_refactor_role_system into 7837a9b on dev.

@aloeser aloeser changed the title 627 roles are no longer in a hierarchy 672 roles are no longer in a hierarchy Sep 3, 2017
Conflicts:
	app/models/ability.rb
@bjrne bjrne temporarily deployed to workshopportal-pr-681 June 2, 2018 09:29 Inactive
@bjrne bjrne temporarily deployed to workshopportal-pr-681 June 2, 2018 09:34 Inactive
@bjrne bjrne temporarily deployed to workshopportal-pr-681 June 2, 2018 09:39 Inactive
@bjrne bjrne temporarily deployed to workshopportal-pr-681 June 2, 2018 10:07 Inactive
@bjrne bjrne temporarily deployed to workshopportal-pr-681 June 2, 2018 10:07 Inactive
@bjrne bjrne temporarily deployed to workshopportal-pr-681 June 2, 2018 12:21 Inactive
Copy link
Member

@cmfcmf cmfcmf left a comment

Choose a reason for hiding this comment

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

There are some minor things I found - mostly formatting. I'll now look at the permission changes themselves.

@@ -4,7 +4,7 @@ class Ability
def initialize(user)
# Define abilities for the passed in user here. For example:
#
# user ||= User.new # guest user (not logged in)
# user ||= User.new # guest user [not logged in]
Copy link
Member

Choose a reason for hiding this comment

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

A bit eager with the brace removal :-D


# Organizers can update user roles of pupil, coach and organizer, but cannot manage admins and cannot update a role to admin
can :manage, User, role: %w(pupil coach organizer)
can :manage, User, role: %w[pupil coach organizer]
Copy link
Member

Choose a reason for hiding this comment

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

Why is this %w?

Copy link
Member

@cmfcmf cmfcmf left a comment

Choose a reason for hiding this comment

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

Noice!

@ekrebs5 ekrebs5 merged commit b6a5eca into dev Jun 2, 2018
@ekrebs5 ekrebs5 deleted the 672_refactor_role_system branch June 2, 2018 12:57
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.

6 participants