]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/messages_controller_test.rb
Rename messages#read to #show
[rails.git] / test / controllers / messages_controller_test.rb
index a4f504ebcc21c04338500d5e480a644825e77cbb..b7bc3bad0cd8eb47bd131df8f76033a493d7980d 100644 (file)
@@ -22,7 +22,7 @@ class MessagesControllerTest < ActionController::TestCase
     )
     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 },
@@ -261,50 +261,50 @@ class MessagesControllerTest < ActionController::TestCase
   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