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

Add support for recursive inclusion of roles #12

Merged
merged 2 commits into from
Dec 19, 2018
Merged

Conversation

tlconnor
Copy link
Contributor

@tlconnor tlconnor commented Dec 18, 2018

This PR fixes a bug where multiple levels of role inclusion do not work.

For example, given the roles defined below, a user with role :test_role would not include the role :lowest_role.

      authorization do
        role :test_role do
          includes :lower_role
          has_permission_on :permissions, :to => :test
        end
        role :lower_role do
          has_permission_on :permissions, :to => :lower
          includes :lowest_role
        end
        role :lowest_role do
          has_permission_on :permissions, :to => :lowest
        end
      end

Copy link
Contributor

@almgong almgong left a comment

Choose a reason for hiding this comment

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

Overall looks great, but had one question about a test

:user => MockUser.new(:test_role))
end

def test_role_hierarchy__recursive__circular
Copy link
Contributor

Choose a reason for hiding this comment

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

Would there be value in checking in this test that the mock user is allowed to access the :lowest action to see that the framework supports roles that are both recursive and circular down to the lowest child?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I have updated the test.

@tlconnor tlconnor merged commit 97521c2 into master Dec 19, 2018
@tlconnor tlconnor deleted the tcRecursiveRoles branch December 19, 2018 01:22
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