Sha256: fc94e5a0d3f104534130c18cc2d0e9b3ee5bed2aeb387c56fb8ace21bb80b8a4

Contents?: true

Size: 976 Bytes

Versions: 25

Compression:

Stored size: 976 Bytes

Contents

require 'helper'

class ControllerTest < ActiveSupport::TestCase
  include Challah

  context "A controller" do
    setup do
      @user = create(:user)
      @controller = MockController.new
    end

    should "be signed out by default" do
      assert_equal false, @controller.send(:current_user?)
    end

    should "have signed_in? and current_user methods" do
      session = Session.create(@user)
      session.save

      assert_equal true, @controller.send(:current_user?)
      assert_equal true, @controller.send(:signed_in?)
      assert_equal @user, @controller.send(:current_user)
    end

    should "redirect to login page if user is not logged in" do
      @controller.request.url = 'http://example.com/protected-page'
      @controller.stubs(:signed_in?).returns(false)
      @controller.expects(:redirect_to)
      @controller.send(:signin_required)

      assert_equal @controller.session[:return_to], 'http://example.com/protected-page'
    end
  end
end

Version data entries

25 entries across 24 versions & 2 rubygems

Version Path
challah-1.1.0 test/controller_test.rb
challah-1.0.0 test/controller_test.rb
challah-1.0.0.beta3 test/controller_test.rb
challah-1.0.0.beta2 test/controller_test.rb
challah-1.0.0.beta test/controller_test.rb
challah-0.9.1.beta.3 test/controller_test.rb
challah-0.9.1.beta.2 test/controller_test.rb
challah-0.9.1.beta test/controller_test.rb
challah-0.9.0 test/controller_test.rb
challah-0.9.0.pre test/controller_test.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/test/controller_test.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/test/controller_test.rb
challah-0.8.3 test/controller_test.rb
challah-0.8.2 test/controller_test.rb
challah-0.8.1 test/controller_test.rb
challah-0.8.0 test/controller_test.rb
challah-rolls-0.1.0 vendor/bundle/gems/challah-0.8.0.pre/test/controller_test.rb
challah-0.8.0.pre test/controller_test.rb
challah-0.7.1 test/controller_test.rb
challah-0.7.0 test/controller_test.rb