Sha256: b889b3ae3c40c68735d164df3da6f66e8763a8ecfa42f4999e1c63fe818d32f9
Contents?: true
Size: 1.94 KB
Versions: 3
Compression:
Stored size: 1.94 KB
Contents
require 'spec_helper' require 'fixtures/models' module CanTango::Ability::Mode class NoCache def calculate_rules can :write, Post end end end describe CanTango::Ability::Executor::Modal do before do @user = User.new 'admin', 'admin@mail.ru' @ability = CanTango::Ability::Base.new @user end context 'Build using build method with candidate' do subject do CanTango::Ability::Executor::Modal.build @user, :modes => [:no_cache] end specify { subject.ability.should be_a CanTango::Ability::Base } specify { subject.candidate.should be_a User } specify { subject.modes.should == [:no_cache] } specify { subject.options[:modes].should == [:no_cache] } specify { subject.should respond_to :can? } specify { subject.can?(:write, Post).should be_true } specify { subject.can?(:publish, Post).should be_false } end context 'Set execution mode to :no_cache using option' do subject do CanTango::Ability::Executor::Modal.new @ability, :modes => [:no_cache] end specify { subject.ability.should be_a CanTango::Ability::Base } specify { subject.candidate.should be_a User } specify { subject.modes.should == [:no_cache] } specify { subject.options[:modes].should == [:no_cache] } specify { subject.should respond_to :can? } specify { subject.can?(:write, Post).should be_true } specify { subject.can?(:publish, Post).should be_false } end context 'Set execution mode to :no_cache' do subject do CanTango::Ability::Executor::Modal.new @ability, :no_cache end specify { subject.should respond_to :can? } specify { subject.should respond_to :cannot? } describe 'rules should have been calculated' do specify { subject.rules.should_not be_empty } specify { subject.rules.size.should == 1 } specify { subject.rules.first.should be_a CanCan::Rule } specify { subject.can?(:write, Post).should be_true } end end end
Version data entries
3 entries across 3 versions & 1 rubygems