Sha256: 99ccf5a72ca965c6b941ccb5a126517faf8628db6f129d5b96ee088bdc1f09f7

Contents?: true

Size: 791 Bytes

Versions: 17

Compression:

Stored size: 791 Bytes

Contents

require 'active_support/concern'

module Authentication
  extend ActiveSupport::Concern

  def login(role = nil)
    logout
    user(role)
    visit new_user_session_path(lang: :de)
    fill_in 'E-Mail', with: user.email
    fill_in 'Passwort', with: user.password
    click_button 'Anmelden'
  end

  def logout
    visit dashboard_path(lang: :de)
    click_link_or_button 'Abmelden' if page.has_link?('Abmelden')
    @user.try(:destroy)
    @user = nil
  end

  def user(role = nil)
    @user ||= User.find_or_create_by(email: 'testuser@iqvoc.local') do |u|
      u.forename = 'Test'
      u.surname = 'User'
      u.password = 'omgomgomg'
      u.password_confirmation = 'omgomgomg'
      u.role = 'reader'
      u.active = true
      u.role = role || User.default_role
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
iqvoc-4.13.0 test/authentication.rb
iqvoc-4.12.1 test/authentication.rb
iqvoc-4.12.0 test/authentication.rb
iqvoc-4.11.1 test/authentication.rb
iqvoc-4.11.0 test/authentication.rb
iqvoc-4.10.0 test/authentication.rb
iqvoc-4.9.0 test/authentication.rb
iqvoc-4.8.2 test/authentication.rb
iqvoc-4.8.1 test/authentication.rb
iqvoc-4.8.0 test/authentication.rb
iqvoc-4.7.0 test/authentication.rb
iqvoc-4.6.1 test/authentication.rb
iqvoc-4.5.2 test/authentication.rb
iqvoc-4.6.0 test/authentication.rb
iqvoc-4.5.1 test/authentication.rb
iqvoc-4.5.0 test/authentication.rb
iqvoc-4.4.0 test/authentication.rb