Sha256: 74071f13f61fea0769fd2a610cfa6b3a601f1225351ce8cee2e8fc171965ff55

Contents?: true

Size: 1.03 KB

Versions: 10

Compression:

Stored size: 1.03 KB

Contents

require '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

10 entries across 10 versions & 1 rubygems

Version Path
challah-1.1.0 test/sessions_controller_test.rb
challah-1.0.0 test/sessions_controller_test.rb
challah-1.0.0.beta3 test/sessions_controller_test.rb
challah-1.0.0.beta2 test/sessions_controller_test.rb
challah-1.0.0.beta test/sessions_controller_test.rb
challah-0.9.1.beta.3 test/sessions_controller_test.rb
challah-0.9.1.beta.2 test/sessions_controller_test.rb
challah-0.9.1.beta test/sessions_controller_test.rb
challah-0.9.0 test/sessions_controller_test.rb
challah-0.9.0.pre test/sessions_controller_test.rb