]> git.openstreetmap.org Git - rails.git/commitdiff
Use a resourceful path for message marking
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 5 Sep 2018 03:02:56 +0000 (11:02 +0800)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 5 Sep 2018 03:23:53 +0000 (11:23 +0800)
app/views/messages/_message_summary.html.erb
app/views/messages/show.html.erb
config/routes.rb
test/controllers/messages_controller_test.rb

index b31b5c526ff84667b1c0d7ff13e121f43877a8eb..6ed41a0e0bf984eb8296dbf575597d92791dad44 100644 (file)
@@ -2,7 +2,7 @@
   <td class="inbox-sender"><%= link_to h(message_summary.sender.display_name), user_path(message_summary.sender) %></td>
   <td class="inbox-subject"><%= link_to h(message_summary.title), message_path(message_summary) %></td>
   <td class="inbox-sent"><%= l message_summary.sent_on, :format => :friendly %></td>
-  <td class="inbox-mark-unread"><%= button_to t('.unread_button'), mark_message_path(message_summary, :mark => 'unread'), { :remote => true } %></td>
-  <td class="inbox-mark-read"><%= button_to t('.read_button'), mark_message_path(message_summary, :mark => 'read'), { :remote => true } %></td>
+  <td class="inbox-mark-unread"><%= button_to t('.unread_button'), message_mark_path(message_summary, :mark => 'unread'), { :remote => true } %></td>
+  <td class="inbox-mark-read"><%= button_to t('.read_button'), message_mark_path(message_summary, :mark => 'read'), { :remote => true } %></td>
   <td class="inbox-destroy"><%= button_to t('.destroy_button'), message_path(message_summary, :referer => request.fullpath), { :method => :delete, :remote => true } %></td>
 </tr>
index 90744466b25ee22b2f59e8797e6df3fb99e4f178..6ea46fcc67b1957ab42152ac5f00e9b7260c0c8b 100644 (file)
@@ -15,7 +15,7 @@
 
   <div class='message-buttons buttons'>
     <%= button_to t('.reply_button'), reply_message_path(@message), :class => 'reply-button' %>
-    <%= button_to t('.unread_button'), mark_message_path(@message, :mark => 'unread'), :class => 'mark-unread-button' %>
+    <%= button_to t('.unread_button'), message_mark_path(@message, :mark => 'unread'), :class => 'mark-unread-button' %>
     <%= button_to t('.destroy_button'), message_path(@message), :method => 'delete', :class => 'destroy-button' %>
 
 <% else %>
index db6b9989a38dbf47773befccc36f9eff05c7cc9b..f3b7fefe42ac0a5873bc8ca5e9030e1461ca7904 100644 (file)
@@ -265,6 +265,7 @@ OpenStreetMap::Application.routes.draw do
 
   # messages
   resources :messages, :only => [:create, :show, :destroy] do
+    post :mark
     collection do
       get :inbox
       get :outbox
@@ -274,7 +275,7 @@ OpenStreetMap::Application.routes.draw do
   get "/user/:display_name/outbox", :to => redirect(:path => "/messages/outbox")
   get "/message/new/:display_name" => "messages#new", :as => "new_message"
   get "/message/read/:message_id", :to => redirect(:path => "/messages/%{message_id}")
-  post "/message/mark/:message_id" => "messages#mark", :as => "mark_message"
+  post "/message/mark/:message_id" => "messages#mark" # remove after deployment
   match "/message/reply/:message_id" => "messages#reply", :via => [:get, :post], :as => "reply_message"
 
   # oauth admin pages (i.e: for setting up new clients, etc...)
index a5043a3f3b6c8f9c59fffac8fde7f6a738a3f177..e3756f04201b18d3812fcef03a9d11c3c7ba02e4 100644 (file)
@@ -25,7 +25,7 @@ class MessagesControllerTest < ActionController::TestCase
       { :controller => "messages", :action => "show", :id => "1" }
     )
     assert_routing(
-      { :path => "/message/mark/1", :method => :post },
+      { :path => "/messages/1/mark", :method => :post },
       { :controller => "messages", :action => "mark", :message_id => "1" }
     )
     assert_routing(