before_action :lookup_user, :only => [:new]
before_action :check_database_readable
before_action :check_database_writable, :only => [:new, :reply, :mark]
- before_action :allow_thirdparty_images, :only => [:new, :read]
+ before_action :allow_thirdparty_images, :only => [:new, :show]
# Allow the user to write a new message to another user. This action also
# deals with the sending of that message to the other user when the user
end
# Show a message
- def read
+ def show
@title = t ".title"
@message = Message.find(params[:message_id])
<tr id="inbox-<%= message_summary.id %>" class="inbox-row<%= "-unread" if not message_summary.message_read? %>">
<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), read_message_path(message_summary) %></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>
get "/user/:display_name/inbox" => "messages#inbox", :as => "inbox"
get "/user/:display_name/outbox" => "messages#outbox", :as => "outbox"
match "/message/new/:display_name" => "messages#new", :via => [:get, :post], :as => "new_message"
- get "/message/read/:message_id" => "messages#read", :as => "read_message"
+ get "/message/read/:message_id" => "messages#show", :as => "message"
post "/message/mark/:message_id" => "messages#mark", :as => "mark_message"
get "/message/reply/:message_id" => "messages#reply", :as => "reply_message"
post "/message/delete/:message_id" => "messages#destroy", :as => "destroy_message"
)
assert_routing(
{ :path => "/message/read/1", :method => :get },
- { :controller => "messages", :action => "read", :message_id => "1" }
+ { :controller => "messages", :action => "show", :message_id => "1" }
)
assert_routing(
{ :path => "/message/mark/1", :method => :post },
end
##
- # test the read action
- def test_read
+ # test the show action
+ def test_show
user = create(:user)
recipient_user = create(:user)
other_user = create(:user)
unread_message = create(:message, :unread, :sender => user, :recipient => recipient_user)
- # Check that the read message page requires us to login
- get :read, :params => { :message_id => unread_message.id }
- assert_redirected_to login_path(:referer => read_message_path(:message_id => unread_message.id))
+ # Check that the show message page requires us to login
+ get :show, :params => { :message_id => unread_message.id }
+ assert_redirected_to login_path(:referer => message_path(:message_id => unread_message.id))
# Login as the wrong user
session[:user] = other_user.id
# Check that we can't read the message
- get :read, :params => { :message_id => unread_message.id }
- assert_redirected_to login_path(:referer => read_message_path(:message_id => unread_message.id))
+ get :show, :params => { :message_id => unread_message.id }
+ assert_redirected_to login_path(:referer => message_path(:message_id => unread_message.id))
assert_equal "You are logged in as `#{other_user.display_name}' but the message you have asked to read was not sent by or to that user. Please login as the correct user in order to read it.", flash[:notice]
# Login as the message sender
session[:user] = user.id
# Check that the message sender can read the message
- get :read, :params => { :message_id => unread_message.id }
+ get :show, :params => { :message_id => unread_message.id }
assert_response :success
- assert_template "read"
+ assert_template "show"
assert_equal false, Message.find(unread_message.id).message_read
# Login as the message recipient
session[:user] = recipient_user.id
# Check that the message recipient can read the message
- get :read, :params => { :message_id => unread_message.id }
+ get :show, :params => { :message_id => unread_message.id }
assert_response :success
- assert_template "read"
+ assert_template "show"
assert_equal true, Message.find(unread_message.id).message_read
# Asking to read a message with no ID should fail
assert_raise ActionController::UrlGenerationError do
- get :read
+ get :show
end
# Asking to read a message with a bogus ID should fail
- get :read, :params => { :message_id => 99999 }
+ get :show, :params => { :message_id => 99999 }
assert_response :not_found
assert_template "no_such_message"
end