diff --git a/app/controllers/preferences_controller.rb b/app/controllers/preferences_controller.rb
index 1d96766ef2..910f6a24fc 100644
--- a/app/controllers/preferences_controller.rb
+++ b/app/controllers/preferences_controller.rb
@@ -11,8 +11,6 @@ class PreferencesController < ApplicationController
def show; end
- def edit; end
-
def update
current_user.languages = params[:user][:languages].split(",")
@@ -40,7 +38,7 @@ def update
redirect_to preferences_path
else
flash.now[:error] = t ".failure"
- render :edit
+ render :show
end
end
end
diff --git a/app/views/preferences/edit.html.erb b/app/views/preferences/edit.html.erb
deleted file mode 100644
index aaf07e927e..0000000000
--- a/app/views/preferences/edit.html.erb
+++ /dev/null
@@ -1,28 +0,0 @@
-<% content_for :heading do %>
-
<%= t ".title" %>
-<% end %>
-
-<%= bootstrap_form_for current_user, :url => { :action => :update } do |f| %>
- <%= f.select :preferred_editor, [[t("editor.default", :name => t("editor.#{Settings.default_editor}.name")), "default"]] + Editors::AVAILABLE_EDITORS.collect { |e| [t("editor.#{e}.description"), e] } %>
-
- <%= f.text_field :languages %>
-
-
- <%= label_tag "site_color_scheme", t("preferences.show.preferred_site_color_scheme"), :class => "form-label" %>
- <%= select_tag "site_color_scheme",
- options_for_select(%w[auto light dark].map { |scheme| [t("preferences.show.site_color_schemes.#{scheme}"), scheme] },
- preferred_color_scheme(:site)),
- :class => "form-select" %>
-
-
-
- <%= label_tag "map_color_scheme", t("preferences.show.preferred_map_color_scheme"), :class => "form-label" %>
- <%= select_tag "map_color_scheme",
- options_for_select(%w[auto light dark].map { |scheme| [t("preferences.show.map_color_schemes.#{scheme}"), scheme] },
- preferred_color_scheme(:map)),
- :class => "form-select" %>
-
-
- <%= f.primary t(".save") %>
- <%= link_to t(".cancel"), preferences_path, :class => "btn btn-link" %>
-<% end %>
diff --git a/app/views/preferences/show.html.erb b/app/views/preferences/show.html.erb
index 9bf83cbf1f..f23afda002 100644
--- a/app/views/preferences/show.html.erb
+++ b/app/views/preferences/show.html.erb
@@ -2,36 +2,26 @@
<%= t ".title" %>
<% end %>
-
- - <%= t ".preferred_editor" %>
+<%= bootstrap_form_for current_user, :url => { :action => :update } do |f| %>
+ <%= f.select :preferred_editor, [[t("editor.default", :name => t("editor.#{Settings.default_editor}.name")), "default"]] + Editors::AVAILABLE_EDITORS.collect { |e| [t("editor.#{e}.description"), e] } %>
- <% if current_user.preferred_editor? %>
- - <%= t("editor.#{current_user.preferred_editor}.description") %>
- <% else %>
- - <%= t("editor.default", :name => t("editor.#{Settings.default_editor}.name")) %>
- <% end %>
+ <%= f.text_field :languages %>
- - <%= t ".preferred_languages" %>
+
+ <%= label_tag "site_color_scheme", t(".preferred_site_color_scheme"), :class => "form-label" %>
+ <%= select_tag "site_color_scheme",
+ options_for_select(%w[auto light dark].map { |scheme| [t(".site_color_schemes.#{scheme}"), scheme] },
+ preferred_color_scheme(:site)),
+ :class => "form-select" %>
+
- -
-
- <% current_user.preferred_languages.each do |locale| %>
- - <%= locale %>
- <% end %>
-
-
+
+ <%= label_tag "map_color_scheme", t(".preferred_map_color_scheme"), :class => "form-label" %>
+ <%= select_tag "map_color_scheme",
+ options_for_select(%w[auto light dark].map { |scheme| [t(".map_color_schemes.#{scheme}"), scheme] },
+ preferred_color_scheme(:map)),
+ :class => "form-select" %>
+
- - <%= t ".preferred_site_color_scheme" %>
- -
- <%= t ".site_color_schemes.#{preferred_color_scheme(:site)}" %>
-
-
- - <%= t ".preferred_map_color_scheme" %>
- -
- <%= t ".map_color_schemes.#{preferred_color_scheme(:map)}" %>
-
-
-
-
- <%= link_to t(".edit_preferences"), edit_preferences_path, :class => "btn btn-outline-primary" %>
-
+ <%= f.primary t(".save") %>
+<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 7faf3bebcf..94d095c265 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1841,11 +1841,7 @@ en:
auto: Auto
light: Light
dark: Dark
- edit_preferences: Edit Preferences
- edit:
- title: Edit Preferences
save: Update Preferences
- cancel: Cancel
update:
failure: Couldn't update preferences.
update_success_flash:
diff --git a/config/routes.rb b/config/routes.rb
index 0e00da9e3b..5bda1b37c3 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -281,7 +281,8 @@
resource :deletion, :only => [:show]
end
resource :dashboard, :only => [:show]
- resource :preferences, :only => [:show, :edit, :update]
+ resource :preferences, :only => [:show, :update]
+ get "/preferences/edit", :to => redirect(:path => "/preferences")
resource :profile, :only => [:edit, :update]
# friendships
diff --git a/test/controllers/preferences_controller_test.rb b/test/controllers/preferences_controller_test.rb
index 1cd07b7d9f..86fc89a717 100644
--- a/test/controllers/preferences_controller_test.rb
+++ b/test/controllers/preferences_controller_test.rb
@@ -9,11 +9,6 @@ def test_routes
{ :controller => "preferences", :action => "show" }
)
- assert_routing(
- { :path => "/preferences/edit", :method => :get },
- { :controller => "preferences", :action => "edit" }
- )
-
assert_routing(
{ :path => "/preferences", :method => :put },
{ :controller => "preferences", :action => "update" }
@@ -27,35 +22,35 @@ def test_update_preferred_editor
session_for(user)
# Changing to a invalid editor should fail
- user.preferred_editor = "unknown"
- put preferences_path, :params => { :user => user.attributes }
+ put preferences_path, :params => { :user => { :preferred_editor => "unknown", :languages => [] } }
assert_response :success
- assert_template :edit
+ assert_template :show
assert_select ".alert-success", false
assert_select ".alert-danger", true
- assert_select "form > div > select#user_preferred_editor > option[selected]", false
+ user.reload
+ assert_nil user.preferred_editor
assert_equal "light", user.preferences.find_by(:k => "site.color_scheme")&.v
assert_equal "light", user.preferences.find_by(:k => "map.color_scheme")&.v
# Changing to a valid editor should work
- user.preferred_editor = "id"
- put preferences_path, :params => { :user => user.attributes }
+ put preferences_path, :params => { :user => { :preferred_editor => "id", :languages => [] } }
assert_redirected_to preferences_path
follow_redirect!
assert_template :show
assert_select ".alert-success", /^Preferences updated/
- assert_select "dd", "iD (in-browser editor)"
+ user.reload
+ assert_equal "id", user.preferred_editor
assert_equal "light", user.preferences.find_by(:k => "site.color_scheme")&.v
assert_equal "light", user.preferences.find_by(:k => "map.color_scheme")&.v
# Changing to the default editor should work
- user.preferred_editor = "default"
- put preferences_path, :params => { :user => user.attributes }
+ put preferences_path, :params => { :user => { :preferred_editor => "default", :languages => [] } }
assert_redirected_to preferences_path
follow_redirect!
assert_template :show
assert_select ".alert-success", /^Preferences updated/
- assert_select "dd", "Default (currently iD)"
+ user.reload
+ assert_nil user.preferred_editor
assert_equal "light", user.preferences.find_by(:k => "site.color_scheme")&.v
assert_equal "light", user.preferences.find_by(:k => "map.color_scheme")&.v
end
diff --git a/test/system/preferences_test.rb b/test/system/preferences_test.rb
index 59a7209f5b..89728a36ee 100644
--- a/test/system/preferences_test.rb
+++ b/test/system/preferences_test.rb
@@ -4,7 +4,7 @@ class PreferencesTest < ApplicationSystemTestCase
def test_flash_message_shows_in_original_language
sign_in_as(create(:user))
- visit edit_preferences_path
+ visit preferences_path
click_on "Update Preferences"
assert_content "Preferences updated"
@@ -13,7 +13,7 @@ def test_flash_message_shows_in_original_language
def test_flash_message_shows_in_new_language
sign_in_as(create(:user))
- visit edit_preferences_path
+ visit preferences_path
fill_in "Preferred Languages", :with => "fr"
click_on "Update Preferences"
diff --git a/test/system/view_communities_test.rb b/test/system/view_communities_test.rb
index 349d0a5bf7..b4b043edfc 100644
--- a/test/system/view_communities_test.rb
+++ b/test/system/view_communities_test.rb
@@ -11,7 +11,7 @@ def test_lc_links
def test_translated_links
sign_in_as(create(:user))
- visit edit_preferences_path
+ visit preferences_path
fill_in "Preferred Languages", :with => "fr"
click_on "Update Preferences"