Sha256: 7e2c6f5a3a03f964e82d3cee4d7fd53e59b4e726ad643820eebe88bc4b8101cc

Contents?: true

Size: 709 Bytes

Versions: 4

Compression:

Stored size: 709 Bytes

Contents

# frozen_string_literal: true

module MinimalistAuthentication
  module TestHelper
    PASSWORD = "test-password"
    PASSWORD_DIGEST = BCrypt::Password.create(PASSWORD, cost: BCrypt::Engine::MIN_COST)

    def login_as(user_fixture_name, password = PASSWORD)
      post session_path, params: { user: { email: users(user_fixture_name).email, password: } }
    end

    def current_user
      @current_user ||= load_user_from_session
    end

    private

    def load_user_from_session
      MinimalistAuthentication.configuration.user_model.find(session_user_id) if session_user_id
    end

    def session_user_id
      @request.session[MinimalistAuthentication.configuration.session_key]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
minimalist_authentication-3.2.1 lib/minimalist_authentication/test_helper.rb
minimalist_authentication-3.2.0 lib/minimalist_authentication/test_helper.rb
minimalist_authentication-3.1.0 lib/minimalist_authentication/test_helper.rb
minimalist_authentication-3.0.0 lib/minimalist_authentication/test_helper.rb