Matthew Phelan
3 years ago
7 changed files with 43 additions and 9 deletions
@ -0,0 +1,39 @@ |
|||||||
|
require "rails_helper" |
||||||
|
require_relative "../../support/devise" |
||||||
|
|
||||||
|
RSpec.describe Users::PasswordsController, type: :request do |
||||||
|
let(:params) { { user: { email: email } } } |
||||||
|
|
||||||
|
context "when a password reset is requested for a valid email" do |
||||||
|
let(:user) { FactoryBot.create(:user) } |
||||||
|
let(:email) { user.email } |
||||||
|
|
||||||
|
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 |
||||||
|
end |
||||||
|
|
||||||
|
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 |
||||||
|
|
||||||
|
let(:email) { "madeup_email@test.com" } |
||||||
|
|
||||||
|
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 |
||||||
|
end |
||||||
|
end |
@ -1,9 +1,6 @@ |
|||||||
require_relative "./controller_macros" |
require_relative "./controller_macros" |
||||||
|
|
||||||
RSpec.configure do |config| |
RSpec.configure do |config| |
||||||
# For Devise > 4.1.1 |
|
||||||
config.include Devise::Test::ControllerHelpers, type: :controller |
config.include Devise::Test::ControllerHelpers, type: :controller |
||||||
# Use the following instead if you are on Devise <= 4.1.1 |
|
||||||
# config.include Devise::TestHelpers, :type => :controller |
|
||||||
config.extend ControllerMacros, type: :controller |
config.extend ControllerMacros, type: :controller |
||||||
end |
end |
||||||
|
Loading…
Reference in new issue