Sha256: 221512ba660227660621e5812fcd225d2eeec511c3f4f42bfa6883ab9815ca84

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'

if defined?(Devise)
  class DeviseTest < StrongPresenter::TestCase
    def test_sign_in_a_real_user
      user = User.new
      sign_in user

      assert_same user, helper.current_user
    end

    def test_sign_in_a_mock_user
      user = Object.new
      sign_in :user, user

      assert_same user, helper.current_user
    end

    def test_sign_in_a_real_admin
      admin = Admin.new
      sign_in admin

      assert_same admin, helper.current_admin
    end

    def test_sign_in_a_mock_admin
      admin = Object.new
      sign_in :admin, admin

      assert_same admin, helper.current_admin
    end

    def test_sign_out_a_real_user
      user = User.new
      sign_in user
      sign_out user

      assert helper.current_user.nil?
    end

    def test_sign_out_a_mock_user
      user = Object.new
      sign_in :user, user
      sign_out :user

      assert helper.current_user.nil?
    end

    def test_sign_out_without_a_user
      sign_out :user

      assert helper.current_user.nil?
    end

    def test_backwards_compatibility
      user = Object.new
      ActiveSupport::Deprecation.silence do
        sign_in user
      end

      assert_same user, helper.current_user
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
strong_presenter-0.2.2 spec/dummy/test/presenters/test_unit/devise_test.rb
strong_presenter-0.2.1 spec/dummy/test/presenters/test_unit/devise_test.rb
strong_presenter-0.2.0 spec/dummy/test/presenters/test_unit/devise_test.rb
strong_presenter-0.1.0 spec/dummy/test/presenters/test_unit/devise_test.rb