Sha256: 1c9feebcc326c8ba9b76bf40309ceced81aaba41a8b3bc98848f3cc943939b18

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require 'test_helper'

class SessionsControllerTest < ActionController::TestCase
  tests SessionsController

  context "The sessions controller" do
    setup do
      @user = build(:user, :username => 'sessions-user-test')
      @user.password! 'abc123'
      @user.save
    end

    should "have a sign-in page" do
      get :new
      assert_response :success
    end

    should "be able to sign in" 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 '/sign-in'

      Challah::Session.any_instance.unstub(:save)
    end

    should "be able to sign out" do
      get :destroy

      assert_redirected_to '/sign-in'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
challah-1.1.1 test/controllers/sessions_controller_test.rb