Skip to content
This repository was archived by the owner on Jun 10, 2025. It is now read-only.
Open
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
2 changes: 1 addition & 1 deletion lib/access-granted/permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def matches_subject?(subject)
end

def matches_conditions?(subject)
if @block && !subject.is_a?(Class)
if @block
@block.call(subject, @user)
else
matches_hash_conditions?(subject)
Expand Down
6 changes: 0 additions & 6 deletions spec/permission_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@
perm = subject.new(true, :read, sub.class, nil, {}, proc {|el| el.published? })
expect(perm.matches_conditions?(sub)).to eq(true)
end

it "does not match proc conditions when given a class instead of an instance" do
sub = double("Element", published?: true)
perm = subject.new(true, :read, sub.class, nil, {}, proc {|el| el.published? })
expect(perm.matches_conditions?(sub.class)).to eq(true)
end
end

describe "#matches_hash_conditions?" do
Expand Down
2 changes: 1 addition & 1 deletion spec/policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def configure
klass = Class.new do
include AccessGranted::Policy

def configure(user)
def configure
role :member do
can :manage, FakePost
end
Expand Down