A platform for community discussion. Free, open, simple.
DEV: Remove unused routes
Gerhard Schlager0bf753a7396b
diff --git a/app/controllers/email_controller.rb b/app/controllers/email_controller.rbindex a7d283a6b2c..deabbf1ffb5 100644--- a/app/controllers/email_controller.rb+++ b/app/controllers/email_controller.rb@@ -4,11 +4,6 @@ class EmailController < ApplicationControllerlayout 'no_ember'skip_before_action :check_xhr, :preload_json, :redirect_to_login_if_required- before_action :ensure_logged_in, only: :preferences_redirect-- def preferences_redirect- redirect_to path("/u/#{current_user.encoded_username}/preferences/emails")- enddef unsubscribe@not_found = truediff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rbindex 42303354429..8e63e97f669 100644--- a/app/controllers/users_controller.rb+++ b/app/controllers/users_controller.rb@@ -4,7 +4,7 @@ class UsersController < ApplicationControllerskip_before_action :authorize_mini_profiler, only: [:avatar]requires_login only: [- :username, :update, :user_preferences_redirect, :upload_user_image,+ :username, :update, :upload_user_image,:pick_avatar, :destroy_user_image, :destroy, :check_emails,:topic_tracking_state, :preferences, :create_second_factor_totp,:enable_second_factor_totp, :disable_second_factor, :list_second_factors,@@ -16,7 +16,7 @@ class UsersController < ApplicationControllerskip_before_action :check_xhr, only: [:show, :badges, :password_reset_show, :password_reset_update, :update, :account_created,- :activate_account, :perform_account_activation, :user_preferences_redirect, :avatar,+ :activate_account, :perform_account_activation, :avatar,:my_redirect, :toggle_anon, :admin_login, :confirm_admin, :email_login, :summary,:feature_topic, :clear_featured_topic, :bookmarks]@@ -129,10 +129,6 @@ class UsersController < ApplicationControllershowend- def user_preferences_redirect- redirect_to path("/u/#{current_user.encoded_username}/preferences")- end-def updateuser = fetch_user_from_paramsguardian.ensure_can_edit!(user)diff --git a/config/routes.rb b/config/routes.rbindex e04bc60dada..d837af541ba 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -315,8 +315,6 @@ Discourse::Application.routes.draw doend # admin namespace- get "email_preferences" => "email#preferences_redirect", :as => "email_preferences_redirect"-get "email/unsubscribe/:key" => "email#unsubscribe", as: "email_unsubscribe"get "email/unsubscribed" => "email#unsubscribed", as: "email_unsubscribed"post "email/unsubscribe/:key" => "email#perform_unsubscribe", as: "email_perform_unsubscribe"@@ -374,7 +372,6 @@ Discourse::Application.routes.draw doendget "my/*path", to: 'users#my_redirect'- get "user_preferences" => "users#user_preferences_redirect"get ".well-known/change-password", to: redirect(relative_url_root + 'my/preferences/account', status: 302)get "user-cards" => "users#cards", format: :json@@ -442,7 +439,7 @@ Discourse::Application.routes.draw doget({ "#{root_path}/:username" => "users#show", constraints: { username: RouteFormat.username } }.merge(index == 1 ? { as: 'user' } : {}))put "#{root_path}/:username" => "users#update", constraints: { username: RouteFormat.username }, defaults: { format: :json }get "#{root_path}/:username/emails" => "users#check_emails", constraints: { username: RouteFormat.username }- get({ "#{root_path}/:username/preferences" => "users#preferences", constraints: { username: RouteFormat.username } }.merge(index == 1 ? { as: :email_preferences } : {}))+ get "#{root_path}/:username/preferences" => "users#preferences", constraints: { username: RouteFormat.username }get "#{root_path}/:username/preferences/email" => "users_email#index", constraints: { username: RouteFormat.username }get "#{root_path}/:username/preferences/account" => "users#preferences", constraints: { username: RouteFormat.username }get "#{root_path}/:username/preferences/profile" => "users#preferences", constraints: { username: RouteFormat.username }diff --git a/spec/requests/email_controller_spec.rb b/spec/requests/email_controller_spec.rbindex 9c9ab972325..e0764c6aeab 100644--- a/spec/requests/email_controller_spec.rb+++ b/spec/requests/email_controller_spec.rb@@ -169,28 +169,6 @@ RSpec.describe EmailController doendend- context '#preferences_redirect' do- it 'requires you to be logged in' do- get "/email_preferences.json"- expect(response.status).to eq(403)- end-- context 'when logged in' do- it 'redirects to your user preferences' do- user = sign_in(Fabricate(:user))- get "/email_preferences.json"- expect(response).to redirect_to("/u/#{user.username}/preferences/emails")- end-- it "correctly redirects for Unicode usernames" do- SiteSetting.unicode_usernames = true- user = sign_in(Fabricate(:unicode_user))- get "/email_preferences.json"- expect(response).to redirect_to("/u/#{user.encoded_username}/preferences/emails")- end- end- end-context '#unsubscribe' doit 'displays not found if key is not found' donavigate_to_unsubscribe(SecureRandom.hex)diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rbindex 9ec957d1c9c..d6edb84c063 100644--- a/spec/requests/users_controller_spec.rb+++ b/spec/requests/users_controller_spec.rb@@ -3496,26 +3496,6 @@ describe UsersController doendend- describe '#user_preferences_redirect' do- it 'requires the user to be logged in' do- get '/user_preferences'- expect(response.status).to eq(404)- end-- it "redirects to their profile when logged in" do- sign_in(user)- get '/user_preferences'- expect(response).to redirect_to("/u/#{user.username}/preferences")- end-- it "correctly redirects for Unicode usernames" do- SiteSetting.unicode_usernames = true- user = sign_in(Fabricate(:unicode_user))- get '/user_preferences'- expect(response).to redirect_to("/u/#{user.encoded_username}/preferences")- end- end-describe '#email_login' dobefore doSiteSetting.enable_local_logins_via_email = true