ignore cannot clause with attributes when not checking for with attributes - closes #406
This commit is contained in:
parent
aa83fee7a4
commit
1fb2c0160c
|
@ -97,7 +97,12 @@ module CanCan
|
||||||
end
|
end
|
||||||
|
|
||||||
def matches_attribute?(attribute)
|
def matches_attribute?(attribute)
|
||||||
@attributes.nil? || attribute.nil? || @attributes.include?(attribute.to_sym)
|
# don't consider attributes in a cannot clause when not matching - this can probably be refactored
|
||||||
|
if !@base_behavior && @attributes && attribute.nil?
|
||||||
|
false
|
||||||
|
else
|
||||||
|
@attributes.nil? || attribute.nil? || @attributes.include?(attribute.to_sym)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO deperecate this
|
# TODO deperecate this
|
||||||
|
|
|
@ -345,6 +345,7 @@ describe CanCan::Ability do
|
||||||
@ability.can?(:update, :books, :author).should be_false
|
@ability.can?(:update, :books, :author).should be_false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# Hash Association
|
# Hash Association
|
||||||
|
|
||||||
it "checks permission through association when hash is passed as subject" do
|
it "checks permission through association when hash is passed as subject" do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user