Sha256: 7075a7d5046f7b5eacf7cbde6a71d29e2e70b7d2553c3788bb14a9697d8c04ca

Contents?: true

Size: 1.88 KB

Versions: 1

Compression:

Stored size: 1.88 KB

Contents

require 'test_helper'

class SignInTest < ActionController::IntegrationTest
  
  context 'Signing in as a User' do
    
    context 'who is not in the system' do
      
      should 'see a failure message' do
        sign_in_as('someone@somewhere.com', 'password')
        assert_match(/Bad email or password/, response.body)
      end
      
      should 'not be signed in' do
        sign_in_as "someone@somewhere.com", 'password'
        assert !controller.signed_in?
      end
      
    end
    
    context 'when confirmed' do
      
      setup do
        @user = Factory(:user, :email => "bob@bob.bob", :password => "password")
      end
      
      should 'be signed in' do
        sign_in_as 'bob@bob.bob', 'password'
        assert controller.signed_in?
      end
      
      should 'see "Signed In"' do
        sign_in_as 'bob@bob.bob', 'password'
        assert_match %r{Signed in}, @response.body
      end
      
      should 'be signed in on subsequent requests' do
        sign_in_as 'bob@bob.bob', 'password'
        reset_session
        visit root_url
        assert controller.signed_in?
      end
      
      should 'redirect back to tender' do
        sign_in_as 'bob@bob.bob', 'password', sign_in_url(:to => 'http://help.twongo.com')
        assert_response :redirect
        assert_match(%r{\Ahttp://help.twongo.com/\?sso=}, response['Location'])
      end
      
    end
        
    context 'when confirmed but with bad credentials' do
      
      setup do
        @user = Factory(:user, :email => 'bob@bob.bob', :password => 'password')
      end
      
      should 'not be signed in' do
        sign_in_as 'bob@bob.bob', 'badpassword'
        assert !controller.signed_in?
      end
      
      should 'see "Bad email or password"' do
        sign_in_as 'bob@bob.bob', 'badpassword'
        assert_match /Bad email or password/, response.body
      end
      
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blue_light_special-0.2.0 test/rails_root/test/integration/sign_in_test.rb