adding a couple things to the changelog
This commit is contained in:
parent
18b45d5cfc
commit
b0cec5251c
@ -1,5 +1,9 @@
|
|||||||
1.4.0 (not yet released)
|
1.4.0 (not yet released)
|
||||||
|
|
||||||
|
* Adding Gemfile; to get specs running just +bundle+ and +rake+ - see issue #163
|
||||||
|
|
||||||
|
* Stop at 'cannot' definition when there are no conditions - see issue #161
|
||||||
|
|
||||||
* The :through option will now call a method with that name if instance variable doesn't exist - see issue #146
|
* The :through option will now call a method with that name if instance variable doesn't exist - see issue #146
|
||||||
|
|
||||||
* Adding :shallow option to load_resource to bring back old behavior of fetching a child without a parent
|
* Adding :shallow option to load_resource to bring back old behavior of fetching a child without a parent
|
||||||
|
@ -224,7 +224,7 @@ module CanCan
|
|||||||
def has_block?(action, subject)
|
def has_block?(action, subject)
|
||||||
relevant_can_definitions(action, subject).any?(&:only_block?)
|
relevant_can_definitions(action, subject).any?(&:only_block?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_raw_sql?(action, subject)
|
def has_raw_sql?(action, subject)
|
||||||
relevant_can_definitions(action, subject).any?(&:only_raw_sql?)
|
relevant_can_definitions(action, subject).any?(&:only_raw_sql?)
|
||||||
end
|
end
|
||||||
@ -271,7 +271,7 @@ module CanCan
|
|||||||
can_definition.relevant? action, subject
|
can_definition.relevant? action, subject
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def relevant_can_definitions_for_match(action, subject)
|
def relevant_can_definitions_for_match(action, subject)
|
||||||
relevant_can_definitions(action, subject).each do |can_definition|
|
relevant_can_definitions(action, subject).each do |can_definition|
|
||||||
if can_definition.only_raw_sql?
|
if can_definition.only_raw_sql?
|
||||||
|
@ -56,7 +56,7 @@ module CanCan
|
|||||||
def only_block?
|
def only_block?
|
||||||
conditions_empty? && !@block.nil?
|
conditions_empty? && !@block.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def only_raw_sql?
|
def only_raw_sql?
|
||||||
@block.nil? && !conditions_empty? && !@conditions.kind_of?(Hash)
|
@block.nil? && !conditions_empty? && !@conditions.kind_of?(Hash)
|
||||||
end
|
end
|
||||||
|
@ -324,7 +324,7 @@ describe CanCan::Ability do
|
|||||||
end
|
end
|
||||||
@ability.should have_block(:read, :foo)
|
@ability.should have_block(:read, :foo)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should know when raw sql is used in conditions" do
|
it "should know when raw sql is used in conditions" do
|
||||||
@ability.can :read, :foo
|
@ability.can :read, :foo
|
||||||
@ability.should_not have_raw_sql(:read, :foo)
|
@ability.should_not have_raw_sql(:read, :foo)
|
||||||
|
@ -56,14 +56,14 @@ describe CanCan::ActiveRecordAdditions do
|
|||||||
stub(@model_class).scoped{|*args| args.inspect}
|
stub(@model_class).scoped{|*args| args.inspect}
|
||||||
@model_class.accessible_by(@ability).should == :found_records
|
@model_class.accessible_by(@ability).should == :found_records
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not allow to fetch records when ability with just block present" do
|
it "should not allow to fetch records when ability with just block present" do
|
||||||
@ability.can :read, @model_class do false end
|
@ability.can :read, @model_class do false end
|
||||||
lambda {
|
lambda {
|
||||||
@model_class.accessible_by(@ability)
|
@model_class.accessible_by(@ability)
|
||||||
}.should raise_error(CanCan::Error)
|
}.should raise_error(CanCan::Error)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not allow to check ability on object when nonhash sql ability definition without block present" do
|
it "should not allow to check ability on object when nonhash sql ability definition without block present" do
|
||||||
@ability.can :read, @model_class, ['bar = ?', 1]
|
@ability.can :read, @model_class, ['bar = ?', 1]
|
||||||
lambda {
|
lambda {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user