Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

require "rails_helper"
require_relative "../../support/devise"
RSpec.describe Users::PasswordsController, type: :request do
3 years ago
let(:params) { { user: { email: email } } }
3 years ago
context "when a password reset is requested for a valid email" do
let(:user) { FactoryBot.create(:user) }
let(:email) { user.email }
3 years ago
it "redirects to the email sent page anyway" do
post "/users/password", params: params
expect(response).to have_http_status(:redirect)
follow_redirect!
expect(response.body).to match(/Check your email/)
end
3 years ago
end
3 years ago
context "when a password reset is requested with an email that doesn't exist in the system" do
before do
allow_any_instance_of(Users::PasswordsController).to receive(:is_navigational_format?).and_return(false)
end
3 years ago
let(:email) { "madeup_email@test.com" }
3 years ago
it "redirects to the email sent page anyway" do
post "/users/password", params: params
expect(response).to have_http_status(:redirect)
follow_redirect!
expect(response.body).to match(/Check your email/)
end
it "shows a flash banner" do
post "/users/password", params: params
follow_redirect!
expect(flash[:notice]).to be_present
end
3 years ago
end
end