Sha256: c531880f17b431b0858e8126ced7df7ae4cacfd0277e97e68aef69e1a1ab7ffd

Contents?: true

Size: 739 Bytes

Versions: 12

Compression:

Stored size: 739 Bytes

Contents

module Sorcery
  module TestHelpers
    module Rails
      module Request
        # Accepts arguments for user to login, the password, route to use and HTTP method
        # Defaults - @user, 'secret', 'user_sessions_url' and http_method: POST
        def login_user(user = nil, password = 'secret', route = nil, http_method = :post)
          user ||= @user
          route ||= user_sessions_url

          username_attr = user.sorcery_config.username_attribute_names.first
          username = user.send(username_attr)
          password_attr = user.sorcery_config.password_attribute_name

          send(http_method, route, params: { "#{username_attr}": username, "#{password_attr}": password })
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sorcery-0.17.0 lib/sorcery/test_helpers/rails/request.rb
sorcery-0.16.5 lib/sorcery/test_helpers/rails/request.rb
sorcery-0.16.4 lib/sorcery/test_helpers/rails/request.rb
sorcery-0.16.3 lib/sorcery/test_helpers/rails/request.rb
sorcery-0.16.2 lib/sorcery/test_helpers/rails/request.rb
sorcery-0.16.1 lib/sorcery/test_helpers/rails/request.rb
sorcery-0.15.1 lib/sorcery/test_helpers/rails/request.rb
sorcery-0.16.0 lib/sorcery/test_helpers/rails/request.rb
sorcery-0.15.0 lib/sorcery/test_helpers/rails/request.rb
sorcery-0.14.0 lib/sorcery/test_helpers/rails/request.rb
sorcery-0.13.0 lib/sorcery/test_helpers/rails/request.rb
sorcery-0.12.0 lib/sorcery/test_helpers/rails/request.rb