Sha256: 83a47222be2db12378880b493b772c8f59e5b9d593f9ea0e9b7c2cae4c4ca0ca
Contents?: true
Size: 1.89 KB
Versions: 4
Compression:
Stored size: 1.89 KB
Contents
require 'cantango/config' require 'fixtures/models' CanTango.configure do |config| config.users.register :user, User config.users.register :admin, Admin config.accounts.register :user, UserAccount config.accounts.register :admin, AdminAccount config.modes.register :no_cache, CanTango::Ability::Mode::NoCache config.ability.mode = :no_cache end require 'spec_helper' require 'helpers/current_user_accounts' class Context include CanTango::Api::Can::Account include_and_extend ::CurrentUserAccounts end module CanTango::Ability::Mode class NoCache def calculate_rules can :edit, Article cannot :edit, User end end end describe CanTango::Api::Can::Account do subject { Context.new } describe 'user_account' do specify do subject.current_account_ability(:user).should be_a CanTango::Ability::Executor::Modal end specify do subject.current_account_ability(:user).modes.should == [:no_cache] end specify do subject.current_account_ability(:user).should respond_to(:can?) end specify do subject.current_account_ability(:user).rules.should_not be_empty end specify do subject.current_account_ability(:user).can?(:edit, Article).should be_true end # user can edit Article, not Admin specify do subject.user_account_can?(:edit, Article).should be_true subject.user_account_can?(:edit, User).should be_false subject.user_account_cannot?(:edit, User).should be_true subject.user_account_cannot?(:edit, Article).should be_false end end describe 'admin_account' do specify do subject.admin_account_can?(:edit, Article).should be_true subject.admin_account_can?(:edit, User).should be_false subject.admin_account_cannot?(:edit, User).should be_true subject.admin_account_cannot?(:edit, Article).should be_false end end end
Version data entries
4 entries across 4 versions & 1 rubygems