Browse Source

Show flash notice

pull/1820/head
Jack S 3 years ago
parent
commit
b2b22d010d
  1. 7
      app/controllers/users_controller.rb
  2. 2
      config/locales/en.yml
  3. 6
      spec/requests/users_controller_spec.rb

7
app/controllers/users_controller.rb

@ -56,13 +56,14 @@ class UsersController < ApplicationController
redirect_to account_path
else
user_name = @user.name&.possessive || @user.email.possessive
case user_params[:active]
when "false"
if user_params[:active] == "false"
@user.update!(confirmed_at: nil, sign_in_count: 0, initial_confirmation_sent: false)
flash[:notice] = I18n.t("devise.activation.deactivated", user_name:)
when "true"
elsif user_params[:active] == "true"
@user.send_confirmation_instructions
flash[:notice] = I18n.t("devise.activation.reactivated", user_name:)
elsif user_params.key?("email") && FeatureToggle.new_email_journey?
flash[:notice] = I18n.t("devise.email.updated", email: @user.unconfirmed_email)
end
redirect_to user_path(@user)
end

2
config/locales/en.yml

@ -684,6 +684,8 @@ Make sure these answers are correct."
hint_text: "This is more than 5 times the income, which is higher than we would expect."
devise:
email:
updated: An email has been sent to %{email} to confirm this change.
two_factor_authentication:
success: "Two-factor authentication successful"
attempt_failed: "Attempt failed"

6
spec/requests/users_controller_spec.rb

@ -1730,6 +1730,12 @@ RSpec.describe UsersController, type: :request do
allow(FeatureToggle).to receive(:new_email_journey?).and_return(true)
end
it "shows flash notice" do
patch("/users/#{other_user.id}", headers:, params:)
expect(flash[:notice]).to eq("An email has been sent to #{new_email} to confirm this change.")
end
it "sends a new flow emails" do
expect(notify_client).to receive(:send_email).with(
email_address: other_user.email,

Loading…
Cancel
Save