<commit_before>require 'test_helper'

module Shoppe
  class PasswordResetsControllerTest
    class GetNewTest < ControllerTestCase
      test "should render 200 response when GETing new action" do
        get :new, use_route: :shoppe
        assert_response :success
      end
    end

    class PostCreateTest < ControllerTestCase
      test 'should render 200 response when email_address is not found' do
        post :create, email_address: '<EMAIL>', use_route: :shoppe
        assert_response :success
      end

      test 'should set alert when email_address is not found' do
        post :create, email_address: '<EMAIL>', use_route: :shoppe
        assert_not_nil flash[:alert]
      end

      test 'should redirect to the login page with email prefilled when email_address is found' do
        user = create(:user)
        post :create, email_address: user.email_address, use_route: :shoppe
        assert_redirected_to login_path(email_address: user.email_address)
      end

      test 'should create the user password when email_address is found' do
        user = create(:user)
        old_password = <PASSWORD>.<PASSWORD>
        post :create, email_address: user.email_address, use_route: :shoppe
        assert_not_equal old_password, user.reload.password_digest
      end

      test 'should send the user an email when email_address is found' do
        user = create(:user)
        post :create, email_address: user.email_address, use_route: :shoppe
        mail = ActionMailer::Base.deliveries.last
        assert_equal user.email_address, mail['to'].to_s
      end
    end
  end
end<commit_msg>Add test for flash notice during reset password<commit_after>require 'test_helper'

module Shoppe
  class PasswordResetsControllerTest
    class GetNewTest < ControllerTestCase
      test "should render 200 response when GETing new action" do
        get :new, use_route: :shoppe
        assert_response :success
      end
    end

    class PostCreateTest < ControllerTestCase
      test 'should render 200 response when email_address is not found' do
        post :create, email_address: '<EMAIL>', use_route: :shoppe
        assert_response :success
      end

      test 'should set alert when email_address is not found' do
        post :create, email_address: '<EMAIL>', use_route: :shoppe
        assert_not_nil flash[:alert]
      end

      test 'should redirect to the login page with email prefilled when email_address is found' do
        user = create(:user)
        post :create, email_address: user.email_address, use_route: :shoppe
        assert_redirected_to login_path(email_address: user.email_address)
      end

      test 'should create the user password when email_address is found' do
        user = create(:user)
        old_password = <PASSWORD>.password_digest
        post :create, email_address: user.email_address, use_route: :shoppe
        assert_not_equal old_password, user.reload.password_digest
      end

      test 'should send the user an email when email_address is found' do
        user = create(:user)
        post :create, email_address: user.email_address, use_route: :shoppe
        mail = ActionMailer::Base.deliveries.last
        assert_equal user.email_address, mail['to'].to_s
      end

      test 'should set notice when email_address is found' do
        user = create(:user)
        post :create, email_address: user.email_address, use_route: :shoppe
        assert_not_nil flash[:notice]
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.0647750071653769, 'fraction_numerical': 0.0034393809114359416, 'mean_word_length': 3.0161104718066745, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 10, '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': '2401479', 'n_tokens_mistral': 973, 'n_tokens_neox': 948, 'n_words': 326}