X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/fa00a386647c8d85cf01c356b025ad26b87bcb96..8538f0029b9d947149e4550831e4a8f2f31242c7:/test/controllers/messages_controller_test.rb diff --git a/test/controllers/messages_controller_test.rb b/test/controllers/messages_controller_test.rb index c50eaf562..dfec6346f 100644 --- a/test/controllers/messages_controller_test.rb +++ b/test/controllers/messages_controller_test.rb @@ -64,6 +64,7 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "new" assert_select "title", "Send message | OpenStreetMap" + assert_select "a[href='#{user_path recipient_user}']", :text => recipient_user.display_name assert_select "form[action='/messages']", :count => 1 do assert_select "input[type='hidden'][name='display_name'][value='#{recipient_user.display_name}']" assert_select "input#message_title", :count => 1 @@ -299,6 +300,7 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest get message_path(:id => unread_message) assert_response :success assert_template "show" + assert_select "a[href='#{user_path recipient_user}']", :text => recipient_user.display_name assert_not Message.find(unread_message.id).message_read # Login as the message recipient @@ -308,6 +310,7 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest get message_path(:id => unread_message) assert_response :success assert_template "show" + assert_select "a[href='#{user_path user}']", :text => user.display_name assert Message.find(unread_message.id).message_read # Asking to read a message with no ID should fail @@ -336,9 +339,12 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest get inbox_messages_path assert_response :success assert_template "inbox" - assert_select ".content-inner > table", :count => 1 do - assert_select "tr", :count => 2 - assert_select "tr#inbox-#{read_message.id}.inbox-row", :count => 1 + assert_select ".content-inner > table.messages-table > tbody", :count => 1 do + assert_select "tr", :count => 1 + assert_select "tr#inbox-#{read_message.id}", :count => 1 do + assert_select "a[href='#{user_path read_message.sender}']", :text => read_message.sender.display_name + assert_select "a[href='#{message_path read_message}']", :text => read_message.title + end end end @@ -346,7 +352,7 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest # test the outbox action def test_outbox user = create(:user) - create(:message, :sender => user) + message = create(:message, :sender => user) # Check that the outbox page requires us to login get outbox_messages_path @@ -359,9 +365,12 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest get outbox_messages_path assert_response :success assert_template "outbox" - assert_select ".content-inner > table", :count => 1 do - assert_select "tr", :count => 2 - assert_select "tr.inbox-row", :count => 1 + assert_select ".content-inner > table.messages-table > tbody", :count => 1 do + assert_select "tr", :count => 1 + assert_select "tr#outbox-#{message.id}", :count => 1 do + assert_select "a[href='#{user_path message.recipient}']", :text => message.recipient.display_name + assert_select "a[href='#{message_path message}']", :text => message.title + end end end @@ -399,15 +408,13 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest assert_not Message.find(unread_message.id).message_read # Check that the marking a message read via XHR works - post message_mark_path(:message_id => unread_message, :mark => "read"), :xhr => true - assert_response :success - assert_template "mark" + post message_mark_path(:message_id => unread_message, :mark => "read") + assert_response :see_other assert Message.find(unread_message.id).message_read # Check that the marking a message unread via XHR works - post message_mark_path(:message_id => unread_message, :mark => "unread"), :xhr => true - assert_response :success - assert_template "mark" + post message_mark_path(:message_id => unread_message, :mark => "unread") + assert_response :see_other assert_not Message.find(unread_message.id).message_read # Asking to mark a message with no ID should fail