Use resourceful routing for message replies
This commit is contained in:
parent
db30ea642e
commit
dfe21fec82
4 changed files with 8 additions and 7 deletions
|
@ -70,7 +70,7 @@ class Notifier < ActionMailer::Base
|
|||
@text = message.body
|
||||
@title = message.title
|
||||
@readurl = message_url(message)
|
||||
@replyurl = reply_message_url(message)
|
||||
@replyurl = message_reply_url(message)
|
||||
@author = @from_user
|
||||
|
||||
attach_user_avatar(message.sender)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<div class="richtext"><%= @message.body.to_html %></div>
|
||||
|
||||
<div class='message-buttons buttons'>
|
||||
<%= button_to t('.reply_button'), reply_message_path(@message), :class => 'reply-button' %>
|
||||
<%= button_to t('.reply_button'), message_reply_path(@message), :class => 'reply-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' %>
|
||||
|
||||
|
|
|
@ -266,6 +266,7 @@ OpenStreetMap::Application.routes.draw do
|
|||
# messages
|
||||
resources :messages, :only => [:create, :show, :destroy] do
|
||||
post :mark
|
||||
match :reply, :via => [:get, :post]
|
||||
collection do
|
||||
get :inbox
|
||||
get :outbox
|
||||
|
@ -276,7 +277,7 @@ OpenStreetMap::Application.routes.draw do
|
|||
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" # remove after deployment
|
||||
match "/message/reply/:message_id" => "messages#reply", :via => [:get, :post], :as => "reply_message"
|
||||
match "/message/reply/:message_id" => "messages#reply", :via => [:get, :post] # remove after deployment
|
||||
|
||||
# oauth admin pages (i.e: for setting up new clients, etc...)
|
||||
scope "/user/:display_name" do
|
||||
|
|
|
@ -29,11 +29,11 @@ class MessagesControllerTest < ActionController::TestCase
|
|||
{ :controller => "messages", :action => "mark", :message_id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/message/reply/1", :method => :get },
|
||||
{ :path => "/messages/1/reply", :method => :get },
|
||||
{ :controller => "messages", :action => "reply", :message_id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/message/reply/1", :method => :post },
|
||||
{ :path => "/messages/1/reply", :method => :post },
|
||||
{ :controller => "messages", :action => "reply", :message_id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
|
@ -232,14 +232,14 @@ class MessagesControllerTest < ActionController::TestCase
|
|||
|
||||
# Check that the message reply page requires us to login
|
||||
get :reply, :params => { :message_id => unread_message.id }
|
||||
assert_redirected_to login_path(:referer => reply_message_path(:message_id => unread_message.id))
|
||||
assert_redirected_to login_path(:referer => message_reply_path(:message_id => unread_message.id))
|
||||
|
||||
# Login as the wrong user
|
||||
session[:user] = other_user.id
|
||||
|
||||
# Check that we can't reply to somebody else's message
|
||||
get :reply, :params => { :message_id => unread_message.id }
|
||||
assert_redirected_to login_path(:referer => reply_message_path(:message_id => unread_message.id))
|
||||
assert_redirected_to login_path(:referer => message_reply_path(:message_id => unread_message.id))
|
||||
assert_equal "You are logged in as `#{other_user.display_name}' but the message you have asked to reply to was not sent to that user. Please login as the correct user in order to reply.", flash[:notice]
|
||||
|
||||
# Login as the right user
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue