diff --git a/app/assets/javascripts/templates/forgot.html.haml b/app/assets/javascripts/templates/forgot.html.haml index 79cafc2431..646d5832c2 100644 --- a/app/assets/javascripts/templates/forgot.html.haml +++ b/app/assets/javascripts/templates/forgot.html.haml @@ -19,6 +19,7 @@ %label{for: "email"} Your email %input.title.input-text{name: "email", type: "email", + id: "email", tabindex: 1, "ng-model" => "spree_user.email"} .row diff --git a/config/environments/test.rb b/config/environments/test.rb index e1291ab4b4..dd3413c8f0 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -36,6 +36,7 @@ Openfoodnetwork::Application.configure do # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + config.action_mailer.default_url_options = { :host => "test.host" } end # Allows us to use _url helpers in Rspec diff --git a/spec/features/consumer/authentication_spec.rb b/spec/features/consumer/authentication_spec.rb index 7ad5611aef..77b60290d1 100644 --- a/spec/features/consumer/authentication_spec.rb +++ b/spec/features/consumer/authentication_spec.rb @@ -53,6 +53,26 @@ feature "Authentication", js: true do ActionMailer::Base.deliveries.last.subject.should =~ /Welcome to/ end end + + describe "forgetting passwords" do + before do + ActionMailer::Base.deliveries.clear + select_login_tab "Forgot Password?" + end + + scenario "failing to reset password" do + fill_in "Your email", with: "notanemail@myemail.com" + click_reset_password_button + page.should have_content "Email address not found" + end + + scenario "resetting password" do + fill_in "Your email", with: user.email + click_reset_password_button + page.should have_reset_password + ActionMailer::Base.deliveries.last.subject.should =~ /Password Reset/ + end + end end describe "as medium" do before do diff --git a/spec/support/request/ui_component_helper.rb b/spec/support/request/ui_component_helper.rb index 294259f36b..fcd3ce56f8 100644 --- a/spec/support/request/ui_component_helper.rb +++ b/spec/support/request/ui_component_helper.rb @@ -16,6 +16,10 @@ module UIComponentHelper click_button "Sign up now" end + def click_reset_password_button + click_button "Reset password" + end + def select_login_tab(text) within ".login-modal" do find("a", text: text).click @@ -34,6 +38,10 @@ module UIComponentHelper have_selector ".login-modal" end + def have_reset_password + have_content "An email with instructions on resetting your password has been sent!" + end + def be_logged_in_as(user_or_email) if user_or_email.is_a? Spree::User have_content user_or_email.email