Sha256: 3c9ad6ed3b44e9fa97e4c8a2c32fe98ab6b60744561eae8569b47baf185676b0

Contents?: true

Size: 1.58 KB

Versions: 15

Compression:

Stored size: 1.58 KB

Contents

require 'generic/api/basic/config'

describe Permits::Ability do
  context "Guest user" do
    before :each do
      basic_config :guest
    end

    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      
      @ability.can?(:read, @post).should be_true      
      
      @ability.can?(:read, Article).should be_false
      @ability.can?(:read, @article).should be_false      
    end

    it "should be not able to :update only Comment" do
      @ability.can?(:update, Comment).should be_true
      @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
      basic_config :admin
    end

    it "should be able to :read anything" do
      @ability.can?(:read, Comment).should be_true
      @ability.can?(:read, Post).should be_true      
    end
  
    it "should be not able to :update everything" do
      @ability.can?(:update, Comment).should be_true
      @ability.can?(:update, Post).should be_true
    end
  
    it "should be not able to :create everything" do
      @ability.can?(:create, Comment).should be_true
      @ability.can?(:create, Post).should be_true      
    end
  
    it "should be not able to :update everything" do
      @ability.can?(:destroy, Comment).should be_true
      @ability.can?(:destroy, Post).should be_true
    end
  end
      
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
cancan-permits-0.3.12 spec/generic/api/basic/xgroup.rb
cancan-permits-0.3.11 spec/generic/api/basic/xgroup.rb
cancan-permits-0.3.10 spec/generic/api/basic/xgroup.rb
cancan-permits-0.3.9 spec/generic/api/basic/xgroup.rb
cancan-permits-0.3.8 spec/generic/api/basic/xgroup.rb
cancan-permits-0.3.7 spec/generic/api/basic/xgroup.rb
cancan-permits-0.3.6 spec/generic/api/basic/xgroup.rb
cancan-permits-0.3.5 spec/generic/api/basic/xgroup.rb
cancan-permits-0.3.4 spec/generic/api/basic/xgroup.rb
cancan-permits-0.3.2 spec/generic/api/basic/xgroup.rb
cancan-permits-0.3.1 spec/generic/api/basic/xgroup.rb
cancan-permits-0.3.0 spec/generic/api/basic/xgroup.rb
cancan-permits-0.2.9 spec/generic/api/basic/xgroup.rb
cancan-permits-0.2.8 spec/generic/api/basic/xgroup.rb
cancan-permits-0.2.7 spec/generic/api/basic/xgroup.rb