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

Accesible roles fix #62

Merged
merged 1 commit into from
Nov 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/monarchy/acts_as_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def accessible_roles_for(resource, inheritnce)
resource_roles(resource).order('level desc')
end

accessible_roles.present? ? accessible_roles : descendant_role(resource)
return accessible_roles if accessible_roles.present?
inheritnce ? descendant_role(resource) : Monarchy.role_class.none
end

def resource_and_inheritance_roles(resource)
Expand Down
7 changes: 7 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
it { expect(project_roles).to match_array([manager_role]) }
it { is_expected.to eq([]) }
end

context 'when user has access to child of the memo' do
let!(:child_memo) { create(:memo, parent: memo) }
let!(:memo_member) { create(:member, user: user, hierarchy: child_memo.hierarchy, roles: [member_role]) }

it { is_expected.to eq([]) }
end
end

context 'user has no direct access to memo' do
Expand Down