ignore cannot clause with attributes when not checking for with attributes - closes #406

This commit is contained in:
Ryan Bates 2011-09-28 14:48:26 -07:00
parent aa83fee7a4
commit 1fb2c0160c
2 changed files with 7 additions and 1 deletions

View File

@ -97,8 +97,13 @@ module CanCan
end
def matches_attribute?(attribute)
# 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
# TODO deperecate this
def matches_subject_class?(subject)

View File

@ -345,6 +345,7 @@ describe CanCan::Ability do
@ability.can?(:update, :books, :author).should be_false
end
# Hash Association
it "checks permission through association when hash is passed as subject" do