Sha256: e130d1572d79f0923ccc99298b278e34a23e6b511a75b72a619c3314e6ed6fe4
Contents?: true
Size: 1.64 KB
Versions: 1
Compression:
Stored size: 1.64 KB
Contents
require 'spec_helper' require 'fixtures/models' class AdminPermit < CanTango::Permit::UserType def initialize ability super end protected def static_rules can :read, Article end end describe CanTango::Permit::UserType do before do @user = SimpleUser.new @ability = CanTango::Ability::Base.new @user @permit = AdminPermit.new @ability end subject { @permit } describe 'registration' do describe 'permit types' do specify { CanTango.config.permits.types.registered.should include(:user_type) } end describe 'permits of type' do specify { CanTango.config.permits.registered_for(:user_type, :admin).should == AdminPermit } end end describe 'attributes' do it "should be the permit for the :admin user" do subject.permit_name.should == :admin end it "should have a user candidate" do subject.candidate.should be_a(SimpleUser) end it "should have a user subject" do subject.send(:user).should be_a(SimpleUser) end it "should have an ability" do subject.ability.should be_a(CanTango::Ability::Base) end end context 'config permits' do let(:permits) { CanTango.config.permits } describe 'disable Admin Permit' do before do permits.disable_for :user_type, [:admin, :editor] end it "should have an ability" do subject.disabled?.should be_true end end describe 'enable all Permits' do before do permits.enable_all! end it "should be disabled" do permits.disabled.should be_empty subject.disabled?.should be_false end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cantango-permits-0.1.1 | spec/cantango/permit/user_type_spec.rb |