Sha256: a5108df5cf2c46973274d3d3f2da3089a5ad5182c5f0061dabcb225ef884456a

Contents?: true

Size: 993 Bytes

Versions: 1

Compression:

Stored size: 993 Bytes

Contents

require 'spec_helper'
require 'fixtures/models'
require 'helpers/current_user_accounts'

class Context
  include CanTango::Api::Scope::Account

  include_and_extend ::CurrentUserAccounts
end

class UserAccount
  tango_account
end

class AdminAccount
  tango_account :masquerade
end

describe CanTango::Api::Scope::Account do
  subject { Context.new }

  before do
    subject.current_admin_account.masquerade_as(subject.current_user_account)
  end

  describe 'registered accounts' do
    specify { CanTango.config.accounts.registered.should include(:user, :admin) }
  end

  describe 'scope_account(scope, options)' do 
    specify do
      subject.scope_account :user do |ability|
        ability.subject.class.should == subject.current_user_account.class
      end
    end
  end

  describe 'real_account(scope, options)' do
    specify do
      subject.real_account :admin do |ability|
        ability.subject.class.should == subject.current_admin_account.class
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cantango-api-0.1.1 spec/cantango/api/scope/account_spec.rb