<commit_before>require "rails_helper"

RSpec.describe "Tests about users", type: :request do
  before(:each) do
    stub_civicrm
    @user = FactoryGirl.create(:user)
  end

  it "promoted users lose their old password and need a strong one" do
    sign_in_user(@user)

    # Test that we can see that we're at the /account page fine
    expect(page).to have_content("Personal information")

    # log user out
    click_on "Logout"

    #promote user to activist
    @user.admin = true
    @user.save

    # try to login and see prompt to add password
    sign_in_user(@user)
    expect(page).not_to have_content("Personal information")

    # try navigating anywhere else to make sure they can't get around it
    visit "/admin/action_pages"
    expect(page).to have_content("Your account has been flagged for importance")

    # Submit a strong password and move on like an adult
    fill_in "Current Password", with: <PASSWORD>
    fill_in "New Password", with: "P1" + <PASSWORD>
    fill_in "Confirm New Password", with: "P1" + @<PASSWORD>.password<commit_msg>Fix user promotion password spec<commit_after>require "rails_helper"

RSpec.describe "Tests about users", type: :request do
  before(:each) do
    stub_civicrm
    @user = FactoryGirl.create(:user)
  end

  it "promoted users lose their old password and need a strong one" do
    sign_in_user(@user)

    # Test that we can see that we're at the /account page fine
    expect(page).to have_content("Personal information")

    # log user out
    find("input[value='Logout']", match: :first).click

    #promote user to activist
    @user.admin = true
    @user.save

    # try to login and see prompt to add password
    sign_in_user(@user)
    expect(page).not_to have_content("Personal information")

    # try navigating anywhere else to make sure they can't get around it
    visit "/admin/action_pages"
    expect(page).to have_content("Your account has been flagged for importance")

    # Submit a strong password and move on like an adult
    fill_in "Current Password", with: <PASSWORD>
    fill_in "New Password", with: "P1" + @<PASSWORD>.password
    fill_in "Confirm New Password", with: "P1" + @user.password
{'fraction_non_alphanumeric': 0.0919487648673376, 'fraction_numerical': 0.0018298261665141812, 'mean_word_length': 3.6334745762711864, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '5496341', 'n_tokens_mistral': 676, 'n_tokens_neox': 639, 'n_words': 242}