<commit_before>require 'require_relative' if RUBY_VERSION[0,3] == '1.8'
require_relative 'acceptance_helper'

describe "forgotten password" do
  include AcceptanceHelper

  it "can't find an account that doesn't exist" do
    visit "/forgot_password"
    fill_in "email", :with => "<EMAIL>"
    click_button "Send"

    assert_match "Your account could not be found, please check your email and try again.", page.body
  end

  it "sets the reset password token" do
    u = Fabricate(:user, :email => "<EMAIL>")
    Notifier.expects(:send_forgot_password_notification)
    assert_nil u.perishable_token

    visit "/forgot_password"
    fill_in "email", :with => "<EMAIL>"
    click_button "Send"

    u = User.first(:email => "<EMAIL>")
    refute u.perishable_token.nil?
    assert_match "A link to reset your password has been sent to <EMAIL>.", page.body
  end
end<commit_msg>Making these tests a bit more specific than matching the body, which can sometimes match an error page<commit_after>require 'require_relative' if RUBY_VERSION[0,3] == '1.8'
require_relative 'acceptance_helper'

describe "forgotten password" do
  include AcceptanceHelper

  it "can't find an account that doesn't exist" do
    visit "/forgot_password"
    fill_in "email", :with => "<EMAIL>"
    click_button "Send"

    within flash do
      assert has_content? "Your account could not be found, please check your email and try again."
    end
  end

  it "sets the reset password token" do
    u = Fabricate(:user, :email => "<EMAIL>")
    Notifier.expects(:send_forgot_password_notification)
    assert_nil u.perishable_token

    visit "/forgot_password"
    fill_in "email", :with => "<EMAIL>"
    click_button "Send"

    u = User.first(:email => "<EMAIL>")

    refute u.perishable_token.nil?
    within "p" do
      assert has_content? "A link to reset your password has been sent to <EMAIL>."
    end
  end
  end
end
{'fraction_non_alphanumeric': 0.10241596638655462, 'fraction_numerical': 0.004201680672268907, 'mean_word_length': 3.8106060606060606, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, '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': '1069484', 'n_tokens_mistral': 610, 'n_tokens_neox': 593, 'n_words': 201}