Skip to content

Commit

Permalink
Use resourceful route for new message
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKhorev committed Jan 2, 2025
1 parent d38f648 commit d57033f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/messages_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit d57033f

Please sign in to comment.