Sha256: 74839b662ab6b08449f5553827cf56f22816f6e669e0e3b8d710b9cdff5edc88

Contents?: true

Size: 978 Bytes

Versions: 7

Compression:

Stored size: 978 Bytes

Contents

require 'spec_helper'

describe Permits::Ability do
  context "Editor user" do
    before :each do
      @editor = User.new(1, :editor, 'kristian')
      @ability = Permits::Ability.new @editor
      @comment  = Comment.new(1)
      @post     = Post.new(1)
      @article  = Article.new('kristian')      
    end
   
    it "should be able to :read Comment he owns, using default :user_id relation - foreign key to User.id" do
      @ability.should be_able_to(:read, Comment)
      @ability.should be_able_to(:read, @comment)      
    end

    it "should be able to :read Post he owns, using :owner relation - foreign key to User.id" do
      @ability.should be_able_to(:read, Post)
      @ability.should be_able_to(:read, @post)      
    end
    
    it "should be able to :read Article he owns, using :author relation - foreign key to User.name" do
      @ability.should be_able_to(:read, Article)
      @ability.should be_able_to(:read, @article)
    end 
  end        
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cancan-permits-0.2.3 spec/generic/permits/owner_permits_spec.rb
cancan-permits-0.2.2 spec/cancan-permits/permits/owner_permits_spec.rb
cancan-permits-0.2.1 spec/cancan-permits/permits/owner_permits_spec.rb
cancan-permits-0.1.4 spec/cancan-permits/permits/owner_permits_spec.rb
cancan-permits-0.1.3 spec/cancan-permits/permits/owner_permits_spec.rb
cancan-permits-0.1.2 spec/cancan-permits/permits/owner_permits_spec.rb
cancan-permits-0.1.1 spec/cancan-permits/permits/owner_permits_spec.rb