Add flash message for email confirmation (#12450)
* Add flash message for email confirmation * Fix spec
This commit is contained in:
parent
e46b537e91
commit
12a8fbddb5
3 changed files with 30 additions and 2 deletions
13
app/controllers/confirmations_controller.rb
Normal file
13
app/controllers/confirmations_controller.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
class ConfirmationsController < Devise::ConfirmationsController
|
||||
FLASH_MESSAGE = "Email sent! Please contact support at %<email>s if you are "\
|
||||
"having trouble receiving your confirmation instructions.".freeze
|
||||
|
||||
def create
|
||||
self.resource = resource_class.send_confirmation_instructions(resource_params)
|
||||
resource.errors.clear # Don't leak user information, like paranoid mode.
|
||||
|
||||
message = format(FLASH_MESSAGE, email: SiteConfig.email_addresses[:members])
|
||||
flash.now[:global_notice] = message
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
|
@ -11,12 +11,13 @@ Rails.application.routes.draw do
|
|||
omniauth_callbacks: "omniauth_callbacks",
|
||||
registrations: "registrations",
|
||||
invitations: "invitations",
|
||||
passwords: "passwords"
|
||||
passwords: "passwords",
|
||||
confirmations: "confirmations"
|
||||
}
|
||||
|
||||
devise_scope :user do
|
||||
get "/enter", to: "registrations#new", as: :sign_up
|
||||
get "/confirm-email", to: "devise/confirmations#new"
|
||||
get "/confirm-email", to: "confirmations#new"
|
||||
delete "/sign_out", to: "devise/sessions#destroy"
|
||||
end
|
||||
|
||||
|
|
|
|||
14
spec/system/authentication/user_request_confirmation_spec.rb
Normal file
14
spec/system/authentication/user_request_confirmation_spec.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe "/confirm-email", type: :system do
|
||||
it "stays on the same page and displays a flash message", :aggregate_failures do
|
||||
visit confirm_email_path
|
||||
fill_in "user_email", with: "test@example.com"
|
||||
click_button "Resend confirmation instructions"
|
||||
|
||||
expect(page).to have_current_path(user_confirmation_path)
|
||||
expected_message = format(ConfirmationsController::FLASH_MESSAGE,
|
||||
email: SiteConfig.email_addresses[:members])
|
||||
expect(page).to have_content(expected_message)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue