Skip to content

Commit

Permalink
added more comparison specs to data_mapper_adapter_spec.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
alekseydreval committed Mar 16, 2013
1 parent ff2b632 commit a0d6132
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spec/cancan/ability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion spec/cancan/model_adapters/data_mapper_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.