@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)
<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' %>
# messages
resources :messages, :only => [:create, :show, :destroy] do
post :mark
+ match :reply, :via => [:get, :post]
collection do
get :inbox
get :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" # 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
{ :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(
# 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