mirror of
https://github.com/openstreetmap/openstreetmap-website.git
synced 2025-07-23 05:19:07 +00:00
Redirect to referer from preferences
This commit is contained in:
@ -15,8 +15,9 @@ module Preferences
|
||||
def update
|
||||
if update_preferences
|
||||
# Use a partial so that it is rendered during the next page load in the correct language.
|
||||
flash[:notice] = { :partial => "update_success_flash" }
|
||||
redirect_to :action => :show
|
||||
flash[:notice] = { :partial => "preferences/preferences/update_success_flash" }
|
||||
referer = safe_referer(params[:referer]) if params[:referer]
|
||||
redirect_to referer || { :action => :show }
|
||||
else
|
||||
flash.now[:error] = t "failure", :scope => "preferences.preferences.update"
|
||||
render :show
|
||||
|
@ -61,6 +61,12 @@ module Preferences
|
||||
assert_equal "light", user.preferences.find_by(:k => "map.color_scheme")&.v
|
||||
end
|
||||
|
||||
def test_update_with_referer
|
||||
session_for(create(:user))
|
||||
put basic_preferences_path, :params => { :referer => root_path }
|
||||
assert_redirected_to root_path
|
||||
end
|
||||
|
||||
def test_update_preferred_language_from_en_selecting_fr
|
||||
check_language_change %w[en], "fr", %w[fr]
|
||||
end
|
||||
|
Reference in New Issue
Block a user