spec/mongoid/permits_spec.rb in cancan-permits-0.2.1 vs spec/mongoid/permits_spec.rb in cancan-permits-0.2.2
- old
+ new
@@ -1,37 +1,21 @@
require 'mongoid/spec_helper'
-# class Comment
-# attr_accessor :owner
-# end
-#
-# class Post
-# attr_accessor :writer
-# end
-#
-# class Article
-# attr_accessor :author
-# end
-
describe Permits::Ability do
context "Guest user" do
before :each do
@guest = User.create(:name => "Kristian", :role => "guest")
- @ability = Permits::Ability.new(@guest)
+ @ability = Permits::Ability.new(@guest, :strategy => :orm)
@comment = Comment.create(:user_id => @guest.id)
@post = Post.create(:writer => @guest.id)
@article = Article.create(:author => @guest.id)
end
- # can :read, [Comment, Post]
- # can [:update, :destroy], [Comment]
- # can :create, Article
-
it "should be able to :read Comment and Post but NOT Article" do
@ability.can?(:read, Comment).should be_true
@ability.can?(:read, @comment).should be_true
@ability.can?(:read, Post).should be_true
@@ -46,20 +30,17 @@
@ability.can?(:update, @comment).should be_true
@ability.can?(:update, Post).should be_false
@ability.can?(:update, @post).should be_false
end
-
end
context "Admin user" do
before do
@admin = User.create(:role => 'admin')
@ability = Permits::Ability.new(@admin)
end
- #
- # # can :manage, :all
- #
+
it "should be able to :read anything" do
@ability.can?(:read, Comment).should be_true
@ability.can?(:read, Post).should be_true
end
\ No newline at end of file