Sha256: e3ac77055ab4addfb7e8383658c6e121ee501f5d9deec427c4b14ac34979d066

Contents?: true

Size: 950 Bytes

Versions: 5

Compression:

Stored size: 950 Bytes

Contents

require 'active_record/spec_helper'
require_all File.dirname(__FILE__) + "/../../shared/" 

def preconfigure
  CanTango.configure do |config|
    config.permit_engine.set :on
    config.permission_engine.set :off
  end
end

describe 'Licenses usage' do
  context 'Musicianslicense applied to UserRolePermit' do
    before(:each) {
      preconfigure
      @user = User.create!(:email => "kris@gmail.com", :role => 'user')
    }

    let(:current_user) { @user }
    let(:ability) { current_user_ability(:user) }

    it "should be allowed to read Song" do
      ability.should be_allowed_to(:read, Song)
    end

    it "should be allowed to write Tune" do
      ability.should be_allowed_to(:write, Tune)
    end

    it "should be allowed to manage Concerto" do
      ability.should be_allowed_to(:read, Concerto)
    end

    it "should be allowed to write Tune" do
      ability.should_not be_allowed_to(:manage, Improvisation)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cantango-0.9.4.7 spec/active_record/scenarios/engines/permit_engine/licenses_spec.rb
cantango-0.9.4.6 spec/active_record/scenarios/engines/permit_engine/licenses_spec.rb
cantango-0.9.4.5 spec/active_record/scenarios/engines/permit_engine/licenses_spec.rb
cantango-0.9.4.3 spec/active_record/scenarios/engines/permit_engine/licenses_spec.rb
cantango-0.9.4.2 spec/active_record/scenarios/engines/permit_engine/licenses_spec.rb