When using an existing scope, it should be merged properly to the class. May fix ryanb/cancan#328 :)
This commit is contained in:
parent
81f00f9024
commit
a10243a569
|
@ -87,7 +87,7 @@ module CanCan
|
||||||
|
|
||||||
def database_records
|
def database_records
|
||||||
if override_scope
|
if override_scope
|
||||||
override_scope
|
@model_class.scoped.merge(override_scope)
|
||||||
elsif @model_class.respond_to?(:where) && @model_class.respond_to?(:joins)
|
elsif @model_class.respond_to?(:where) && @model_class.respond_to?(:joins)
|
||||||
@model_class.where(conditions).joins(joins)
|
@model_class.where(conditions).joins(joins)
|
||||||
else
|
else
|
||||||
|
|
|
@ -125,7 +125,7 @@ if ENV["MODEL_ADAPTER"].nil? || ENV["MODEL_ADAPTER"] == "active_record"
|
||||||
Article.accessible_by(@ability).should == [article1]
|
Article.accessible_by(@ability).should == [article1]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should only fetch associated records for nested controllers" do
|
it "should fetch only associated records when using with a scope for conditions" do
|
||||||
@ability.can :read, Article, Article.where(:secret => true)
|
@ability.can :read, Article, Article.where(:secret => true)
|
||||||
category1 = Category.create!(:visible => false)
|
category1 = Category.create!(:visible => false)
|
||||||
category2 = Category.create!(:visible => true)
|
category2 = Category.create!(:visible => true)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user