Sha256: 7f288c7d0adf4d7f96560b48a1b796cf7e6f9bd2143ce7c2475a73ba9fe79714

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require 'helper'

class SessionsControllerTest < ActionController::TestCase
  tests Challah::SessionsController
  
  context "The sessions controller" do
    setup do
      @user = Factory(:user, :username => 'sessions-user-test')
    end
    
    should "have a login page" do
      get :new
      assert_response :success
    end
    
    should "be able to login" do
      Challah::Session.any_instance.stubs(:save).returns(true)
      
      post :create, :username => 'sessions-user-test', :password => 'abc123'
      assert_redirected_to '/'
      
      Challah::Session.any_instance.unstub(:save)
    end
    
    should "send you back to the sign in page if you can't sign in" do
      Challah::Session.any_instance.stubs(:save).returns(false)
      
      post :create, :username => 'sessions-user-test', :password => 'abc123'
      assert_redirected_to '/login'
      
      Challah::Session.any_instance.unstub(:save)
    end 
    
    should "be able to sign out" do
      get :destroy
      
      assert_redirected_to '/login'
    end 
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
challah-0.3.0 test/sessions_controller_test.rb
challah-0.2.1 test/sessions_controller_test.rb
challah-0.2.0 test/sessions_controller_test.rb