Merge pull request #4293 from jasonk357/4031-change-user-email-alert

Improve user email change flash alert message
This commit is contained in:
Luis Ramos
2019-09-30 13:19:40 +01:00
committed by GitHub
3 changed files with 18 additions and 1 deletions

View File

@@ -46,7 +46,12 @@ module Spree
@user.spree_roles = roles.reject(&:blank?).collect{ |r| Spree::Role.find(r) }
end
flash.now[:success] = Spree.t(:account_updated)
message = if new_email_unconfirmed?
Spree.t(:email_updated)
else
Spree.t(:account_updated)
end
flash.now[:success] = message
end
render :edit
end
@@ -126,6 +131,10 @@ module Spree
def load_roles
@roles = Spree::Role.scoped
end
def new_email_unconfirmed?
params[:user][:email] != @user.email
end
end
end
end

View File

@@ -2943,6 +2943,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
email: Email
# TODO: remove 'account_updated' key once we get to Spree 2.0
account_updated: "Account updated!"
email_updated: "The account will be updated once the new email is confirmed."
my_account: "My account"
date: "Date"
time: "Time"

View File

@@ -64,6 +64,13 @@ feature "Managing users" do
expect(page).to have_content("Account updated")
end
it "should let me edit the user email" do
fill_in "Email", with: "newemail@example.org"
click_button "Update"
expect(page).to have_content("The account will be updated once the new email is confirmed.")
end
end
end