Sha256: f6fe9414d08f08a740c6fb01730b7d4978f1efe4a6954c9ecfb223dc006e75dc

Contents?: true

Size: 891 Bytes

Versions: 27

Compression:

Stored size: 891 Bytes

Contents

require 'test_helper'

class ImpersonationTest < ActionController::IntegrationTest
  
  context 'When impersonating another user' do
    
    setup do
      @bob = Factory(:user, :email => 'bob@bob.bob')
      @admin_user = Factory(:admin_user, :email => 'admin@example.com')
      sign_in_as @admin_user.email, @admin_user.password
      impersonate(@bob)
    end
    
    should 'be signed in' do
      assert controller.signed_in?
    end        
    
    should 'be logged in as bob' do
      assert_equal controller.current_user, @bob
    end
    
    should 'be able to go back to the original admin user' do
      click_link "Stop impersonating"
      assert controller.signed_in?
      assert_equal controller.current_user, @admin_user
    end
    
  end
  
  
  private
  
  
  def impersonate(user)
    visit impersonations_url
    click_link "impersonate_#{user.id}"
  end
  
end

Version data entries

27 entries across 26 versions & 4 rubygems

Version Path
headstart-0.11.2 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.11.1 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.9.2 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.9.1 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.9.0 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.8.0 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.7.0 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.6.2 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.6.1 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.6.0 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.5.5 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.5.4 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.5.3 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.5.2 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.5.1 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.5.0 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.4.2 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.4.1 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.4.0 generators/headstart_tests/templates/test/integration/impersonation_test.rb
headstart-0.3.0 generators/headstart_tests/templates/test/integration/impersonation_test.rb