Sha256: e5bc64457064b5cd5b596a03c2470207d7b94514ea0f26a3af15a9f457c860a8

Contents?: true

Size: 969 Bytes

Versions: 2

Compression:

Stored size: 969 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.should == subject.current_user_account
      end
    end
  end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cantango-api-0.1.3 spec/cantango/api/scope/account_spec.rb
cantango-api-0.1.2 spec/cantango/api/scope/account_spec.rb