Ensure that flash message is shown in the updated language
This commit is contained in:
parent
caf2e2a242
commit
403c8941a6
4 changed files with 28 additions and 2 deletions
|
@ -22,7 +22,8 @@ class PreferencesController < ApplicationController
|
|||
params[:user][:preferred_editor]
|
||||
end
|
||||
if current_user.save
|
||||
flash[:notice] = t ".success"
|
||||
# Use a partial so that it is rendered during the next page load in the correct language.
|
||||
flash[:notice] = { :partial => "preferences/update_success_flash" }
|
||||
redirect_to preferences_path
|
||||
else
|
||||
flash[:error] = t ".failure"
|
||||
|
|
1
app/views/preferences/_update_success_flash.html.erb
Normal file
1
app/views/preferences/_update_success_flash.html.erb
Normal file
|
@ -0,0 +1 @@
|
|||
<%= t ".message" %>
|
|
@ -1655,8 +1655,9 @@ en:
|
|||
save: Update Preferences
|
||||
cancel: Cancel
|
||||
update:
|
||||
success: Preferences updated.
|
||||
failure: Couldn't update preferences.
|
||||
update_success_flash:
|
||||
message: Preferences updated.
|
||||
profiles:
|
||||
edit:
|
||||
title: Edit Profile
|
||||
|
|
23
test/system/preferences_test.rb
Normal file
23
test/system/preferences_test.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
require "application_system_test_case"
|
||||
|
||||
class PreferencesTest < ApplicationSystemTestCase
|
||||
def test_flash_message_shows_in_original_language
|
||||
sign_in_as(create(:user))
|
||||
|
||||
visit edit_preferences_path
|
||||
click_on "Update Preferences"
|
||||
|
||||
assert page.has_content?("Preferences updated")
|
||||
end
|
||||
|
||||
def test_flash_message_shows_in_new_language
|
||||
sign_in_as(create(:user))
|
||||
|
||||
visit edit_preferences_path
|
||||
fill_in "Preferred Languages", :with => "fr"
|
||||
click_on "Update Preferences"
|
||||
|
||||
# TODO: enable with french translation when that's available
|
||||
# assert page.has_content?("Préférences mises à jour") # rubocop:disable Style/AsciiComments
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue