<commit_before># This file registers a hook before each system test
# which logs in with/authenticates the <EMAIL> account.

# we need to make sure that Capybara is configured/started before
# this hook. Otherwise a login try is performed while the app/puma
# hasn't started yet.
require_relative './driven_by'

RSpec.configure do |config|

  config.before(:each, type: :system) do |example|

    # there is no way to authenticated in a not set up system
    next if !example.metadata.fetch(:set_up, true)

    # check if authentication should be performed
    authenticated = example.metadata.fetch(:authenticated, true)
    next if authenticated.blank?

    if authenticated.is_a?(Proc)
      user     = instance_exec(&authenticated)
      password = <PASSWORD>

      raise "Can't authenticate user that has no password set" if password.blank?

      credentials = {
        username: user.email,
        password: password,
      }
    else
      credentials = {
        username: '<EMAIL>',
        password: '<PASSWORD>',
      }
    end

    login(credentials)
  end
end<commit_msg>Follow up - 9402699a4209a67bf949a2c72f4344e8585bf7dd - DX: Developer should not need to add a password for each created user that should login. Therefore create one if non is set yet.<commit_after># This file registers a hook before each system test
# which logs in with/authenticates the <EMAIL> account.

# we need to make sure that Capybara is configured/started before
# this hook. Otherwise a login try is performed while the app/puma
# hasn't started yet.
require_relative './driven_by'

RSpec.configure do |config|

  config.before(:each, type: :system) do |example|

    # there is no way to authenticated in a not set up system
    next if !example.metadata.fetch(:set_up, true)

    # check if authentication should be performed
    authenticated = example.metadata.fetch(:authenticated, true)
    next if authenticated.blank?

    if authenticated.is_a?(Proc)
      user     = instance_exec(&authenticated)
      password = <PASSWORD>

      if password.blank?
        password = '<PASSWORD> cap<PASSWORD>'
        user.update!(password: password)
      end

      credentials = {
        username: user.email,
        password: password,
      }
    else
      credentials = {
        username: '<EMAIL>',
        password: '<PASSWORD>',
      }
    end

    login(credentials)
  end
end
{'fraction_non_alphanumeric': 0.0829145728643216, 'fraction_numerical': 0.011725293132328308, 'mean_word_length': 3.021885521885522, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4724756', 'n_tokens_mistral': 705, 'n_tokens_neox': 665, 'n_words': 244}