From d57033fa8700841d58bac81b7a68e050afd1299e Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 2 Jan 2025 10:28:03 +0300 Subject: [PATCH] Use resourceful route for new message --- config/routes.rb | 4 ++-- test/controllers/messages_controller_test.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 3ede0d33d5..4ab8f307b0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -311,7 +311,7 @@ get "/export/embed" => "export#embed" # messages - resources :messages, :id => /\d+/, :only => [:create, :show, :destroy] do + resources :messages, :path_names => { :new => "new/:display_name" }, :id => /\d+/, :only => [:new, :create, :show, :destroy] do post :mark patch :unmute @@ -324,7 +324,7 @@ end get "/user/:display_name/inbox", :to => redirect(:path => "/messages/inbox") get "/user/:display_name/outbox", :to => redirect(:path => "/messages/outbox") - get "/message/new/:display_name" => "messages#new", :as => "new_message" + get "/message/new/:display_name", :to => redirect(:path => "/messages/new/%{display_name}") get "/message/read/:message_id", :to => redirect(:path => "/messages/%{message_id}") # muting users diff --git a/test/controllers/messages_controller_test.rb b/test/controllers/messages_controller_test.rb index ac7ca9a061..f72e695936 100644 --- a/test/controllers/messages_controller_test.rb +++ b/test/controllers/messages_controller_test.rb @@ -5,7 +5,7 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest # test all routes which lead to this controller def test_routes assert_routing( - { :path => "/message/new/username", :method => :get }, + { :path => "/messages/new/username", :method => :get }, { :controller => "messages", :action => "new", :display_name => "username" } ) assert_routing(