<commit_before>module IntegrationMacros
  def create_users_with_roles
    %w(admin writer reader).each do |role|
      get_or_create_user role
    end
  end

  def get_or_create_user(role = :writer)
    user = User.first_or_initialize(username: "#{role}-user", role: role)
    user.save!
    user
  end

  def current_user(role = :writer)
    @current_user ||= get_or_create_user(role)
  end

  def login_user(role = :writer)
    user = get_or_create_user(role)
    visit login_path
    fill_in 'username', with: user.username
    click_button 'Logga in'
  end

  def valid_session(role: :admin)
    current_user = get_or_create_user(role)
    { user_id: current_user.id }
  end
end<commit_msg>Setting session[:expires_at] for controller specs<commit_after>module IntegrationMacros
  def create_users_with_roles
    %w(admin writer reader).each do |role|
      get_or_create_user role
    end
  end

  def get_or_create_user(role = :writer)
    user = User.first_or_initialize(username: "#{role}-user", role: role)
    user.save!
    user
  end

  def current_user(role = :writer)
    @current_user ||= get_or_create_user(role)
  end

  def login_user(role = :writer)
    user = get_or_create_user(role)
    visit login_path
    fill_in 'username', with: user.username
    click_button 'Logga in'
  end

  def valid_session(role: :admin)
    current_user = get_or_create_user(role)
    session[:expires_at] = Time.now + 1.day
    { user_id: current_user.id }
  end
end
{'fraction_non_alphanumeric': 0.09264305177111716, 'fraction_numerical': 0.0006811989100817438, 'mean_word_length': 3.7694805194805197, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1864843', 'n_tokens_mistral': 524, 'n_tokens_neox': 511, 'n_words': 114}