Permalink
Browse files

added more comparison specs to data_mapper_adapter_spec.rb

  • Loading branch information...
1 parent ff2b632 commit a0d6132e3b7d3ba1740204ac3225f35308c3de53 @adrv committed Mar 16, 2013
Showing with 21 additions and 2 deletions.
  1. +1 −1 spec/cancan/ability_spec.rb
  2. +20 −1 spec/cancan/model_adapters/data_mapper_adapter_spec.rb
@@ -19,7 +19,7 @@
it "should pass true to `can?` when non false/nil is returned in block" do
@ability.can :read, :all
@ability.can :read, Symbol do |sym|
- "foo" # TODO test that sym is nil when no instance is passed
+ "foo"
end
@ability.can?(:read, :some_symbol).should == true
end
@@ -114,6 +114,25 @@ class Comment
@ability.should_not be_able_to(:read, article3)
end
- # TODO: add more comparison specs
+ it "should match lt condition" do
+ @ability.can :read, Article, :priority.lt => 4
+ article1 = Article.create(:priority => 4)
+ article2 = Article.create(:priority => 3)
+ Article.accessible_by(@ability).should == [article2]
+ @ability.should be_able_to(:read, article2)
+ @ability.should_not be_able_to(:read, article1)
+ end
+
+ it "should match lte condition" do
+ @ability.can :read, Article, :priority.lte => 4
+ article1 = Article.create(:priority => 5)
+ article2 = Article.create(:priority => 4)
+ article3 = Article.create(:priority => 3)
+ Article.accessible_by(@ability).should == [article2, article3]
+ @ability.should be_able_to(:read, article2)
+ @ability.should be_able_to(:read, article3)
+ @ability.should_not be_able_to(:read, article1)
+ end
+
end
end

0 comments on commit a0d6132

Please sign in to comment.