Sha256: 2f51740b61a5c6b496c7ec366f72ed1c1aea72b6c063142465ffbaa689a9ba62

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

require 'cantango/config'
require 'fixtures/models'

require 'spec_helper'

class EditorAccount
  include CanTango::Api::Masquerade::Account
end

class AdminAccount
  include CanTango::Api::Masquerade::Account
end

CanTango.config.accounts do |ac|
  ac.register :editor, EditorAccount
  ac.register :admin, AdminAccount
end

describe CanTango::Api::Masquerade::Account do
  before do
    @user   = User.new 'mike'
    @editor = EditorAccount.new
    @admin  = AdminAccount.new @user
  end
  
  subject { @admin }
  
  context 'is NOT masquerading' do
    before do
      subject.stop_masquerade
    end

    specify { subject.masquerading.should be_false }

    describe 'masquerading?' do
      specify { subject.masquerading?.should be_false }
    end
  end
  
  context 'IS masquerading' do
    before do
      subject.masquerade_as @editor
    end
    
    specify { subject.masquerading.should be_true }
    
    describe 'masquerade_as account' do
      specify { subject.active_account.should == @editor }
    end

    describe 'stop_masquerade' do
      specify do
        subject.stop_masquerade
        subject.masquerading.should be_false
      end
    end

    describe 'masquerading?' do
      specify { subject.masquerading?.should be_true }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cantango-masquerade-0.1.3.2 spec/cantango/api/masquerade/account_spec.rb
cantango-masquerade-0.1.3.1 spec/cantango/api/masquerade/account_spec.rb
cantango-masquerade-0.1.3 spec/cantango/api/masquerade/account_spec.rb
cantango-masquerade-0.1.2.1 spec/cantango/api/masquerade/account_spec.rb
cantango-masquerade-0.1.2 spec/cantango/api/masquerade/account_spec.rb
cantango-masquerade-0.1.1 spec/cantango/api/masquerade/account_spec.rb