diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index f6c0fb3fa..863aa86ee 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -13,6 +13,16 @@ class UsersController < ApplicationController
respond_with(@user)
end
+ def settings
+ @user = CurrentUser.user
+
+ if @user.is_anonymous?
+ redirect_to new_session_path
+ else
+ respond_with(@user, template: "users/edit")
+ end
+ end
+
def index
if params[:name].present?
@user = User.find_by_name!(params[:name])
diff --git a/app/views/static/site_map.html.erb b/app/views/static/site_map.html.erb
index c77f61cee..6bb745b3d 100644
--- a/app/views/static/site_map.html.erb
+++ b/app/views/static/site_map.html.erb
@@ -120,7 +120,7 @@
<%= link_to "Sign up", new_user_path %>
<% else %>
<%= link_to "Profile", profile_path %>
- <%= link_to "Settings", edit_user_path(CurrentUser.user) %>
+ <%= link_to "Settings", settings_path %>
<% if CurrentUser.is_gold? %>
<%= link_to "Change name", new_user_name_change_request_path %>
<% end %>
diff --git a/app/views/users/_secondary_links.html.erb b/app/views/users/_secondary_links.html.erb
index b8184aef4..272717e75 100644
--- a/app/views/users/_secondary_links.html.erb
+++ b/app/views/users/_secondary_links.html.erb
@@ -11,8 +11,8 @@
<% if @user && !@user.new_record? && !CurrentUser.user.is_anonymous? %>
|
<% if @user.id == CurrentUser.user.id %>
- <%= subnav_link_to "Settings", edit_user_path(CurrentUser.user) %>
<%= subnav_link_to "Profile", profile_path %>
+ <%= subnav_link_to "Settings", settings_path %>
<%= subnav_link_to "Messages #{CurrentUser.user.dmail_count}", dmails_current_folder_path %>
<% if !@user.is_platinum? %>
diff --git a/config/routes.rb b/config/routes.rb
index f8c8f6062..28549d9b2 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -411,6 +411,7 @@ Rails.application.routes.draw do
get "/user/login" => redirect("/sessions/new")
get "/user_record" => redirect {|params, req| "/user_feedbacks?search[user_id]=#{req.params[:user_id]}"}
get "/profile", to: "users#profile", as: :profile
+ get "/settings", to: "users#settings", as: :settings
get "/wiki" => redirect {|params, req| "/wiki_pages?page=#{req.params[:page]}"}
get "/wiki/index" => redirect {|params, req| "/wiki_pages?page=#{req.params[:page]}"}
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index 0b9788d40..d21682780 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -135,21 +135,27 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
end
context "edit action" do
- setup do
- @user = create(:user)
- end
-
should "render" do
get_auth edit_user_path(@user), @user
assert_response :success
end
end
- context "update action" do
- setup do
- @user = create(:user)
+ context "settings action" do
+ should "render" do
+ get_auth settings_path, @user
+
+ assert_response :success
+ assert_select "#page h1", "Settings"
end
+ should "redirect anonymous users to the sign in page" do
+ get settings_path
+ assert_redirected_to new_session_path
+ end
+ end
+
+ context "update action" do
should "update a user" do
put_auth user_path(@user), @user, params: {:user => {:favorite_tags => "xyz"}}
@user.reload