Add MongoidAdapter specs for unsaved instances
This commit is contained in:
parent
12b0bff0b6
commit
9a14c706d2
|
@ -135,6 +135,18 @@ if ENV["MODEL_ADAPTER"] == "mongoid"
|
|||
obj2 = MongoidProject.create(:age => 40)
|
||||
@ability.can?(:read, obj2).should == false
|
||||
end
|
||||
|
||||
it "should handle instance not saved to database" do
|
||||
obj = MongoidProject.new(:title => 'Sir')
|
||||
@ability.can :read, MongoidProject, :title.in => ["Sir", "Madam"]
|
||||
@ability.can?(:read, obj).should == true
|
||||
|
||||
# accessible_by only returns saved records
|
||||
MongoidProject.accessible_by(@ability, :read).entries.should == []
|
||||
|
||||
obj2 = MongoidProject.new(:title => 'Lord')
|
||||
@ability.can?(:read, obj2).should == false
|
||||
end
|
||||
end
|
||||
|
||||
it "should call where with matching ability conditions" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user