Sha256: 70c44442ce66bc0dfca06917515cf27616759d523bd90e9661a084c71b110f63

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 KB

Contents

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

class EditorUser
  include CanTango::Api::Masquerade::User
end

class AdminUser
  include CanTango::Api::Masquerade::User
end

CanTango.config.users do |u|
  u.register :editor, EditorUser
  u.register :admin, AdminUser
end

describe CanTango::Api::Masquerade::User do
  before do
    @editor = EditorUser.new
    @admin  = AdminUser.new 'admin'
  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 user' do
      specify { subject.active_user.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/user_spec.rb
cantango-masquerade-0.1.3.1 spec/cantango/api/masquerade/user_spec.rb
cantango-masquerade-0.1.3 spec/cantango/api/masquerade/user_spec.rb
cantango-masquerade-0.1.2.1 spec/cantango/api/masquerade/user_spec.rb
cantango-masquerade-0.1.2 spec/cantango/api/masquerade/user_spec.rb
cantango-masquerade-0.1.1 spec/cantango/api/masquerade/user_spec.rb