X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/497009ed2b98dfdeeb349e891c1fbd88d14ff087..dd8ebf9b091a7dcf70b0ac728f673f4a48e68d5e:/test/controllers/message_controller_test.rb diff --git a/test/controllers/message_controller_test.rb b/test/controllers/message_controller_test.rb index 1476831cf..427519c32 100644 --- a/test/controllers/message_controller_test.rb +++ b/test/controllers/message_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class MessageControllerTest < ActionController::TestCase fixtures :users, :messages @@ -69,8 +69,8 @@ class MessageControllerTest < ActionController::TestCase assert_difference "ActionMailer::Base.deliveries.size", 0 do assert_difference "Message.count", 0 do post :new, - :display_name => users(:public_user).display_name, - :message => { :title => "Test Message", :body => "" } + :display_name => users(:public_user).display_name, + :message => { :title => "Test Message", :body => "" } end end assert_response :success @@ -88,8 +88,8 @@ class MessageControllerTest < ActionController::TestCase assert_difference "ActionMailer::Base.deliveries.size", 0 do assert_difference "Message.count", 0 do post :new, - :display_name => users(:public_user).display_name, - :message => { :title => "", :body => "Test message body" } + :display_name => users(:public_user).display_name, + :message => { :title => "", :body => "Test message body" } end end assert_response :success @@ -107,14 +107,14 @@ class MessageControllerTest < ActionController::TestCase assert_difference "ActionMailer::Base.deliveries.size", 1 do assert_difference "Message.count", 1 do post :new, - :display_name => users(:public_user).display_name, - :message => { :title => "Test Message", :body => "Test message body" } + :display_name => users(:public_user).display_name, + :message => { :title => "Test Message", :body => "Test message body" } end end assert_redirected_to inbox_path(:display_name => users(:normal_user).display_name) assert_equal "Message sent", flash[:notice] e = ActionMailer::Base.deliveries.first - assert_equal [ users(:public_user).email ], e.to + assert_equal [users(:public_user).email], e.to assert_equal "[OpenStreetMap] Test Message", e.subject assert_match /Test message body/, e.text_part.decoded assert_match /Test message body/, e.html_part.decoded @@ -145,11 +145,11 @@ class MessageControllerTest < ActionController::TestCase assert_no_difference "Message.count" do with_message_limit(0) do post :new, - :display_name => users(:public_user).display_name, - :message => { :title => "Test Message", :body => "Test message body" } + :display_name => users(:public_user).display_name, + :message => { :title => "Test Message", :body => "Test message body" } assert_response :success assert_template "new" - assert_select "p.error", /wait a while/ + assert_select ".error", /wait a while/ end end end @@ -366,8 +366,8 @@ class MessageControllerTest < ActionController::TestCase assert_equal false, m.to_user_visible # Check that the deleting a sent message works - post :delete, :message_id => messages(:unread_message).id - assert_redirected_to inbox_path(:display_name => users(:normal_user).display_name) + post :delete, :message_id => messages(:unread_message).id, :referer => outbox_path(:display_name => users(:normal_user).display_name) + assert_redirected_to outbox_path(:display_name => users(:normal_user).display_name) assert_equal "Message deleted", flash[:notice] m = Message.find(messages(:unread_message).id) assert_equal false, m.from_user_visible @@ -384,7 +384,7 @@ class MessageControllerTest < ActionController::TestCase assert_template "no_such_message" end -private + private def with_message_limit(value) max_messages_per_hour = Object.send("remove_const", "MAX_MESSAGES_PER_HOUR")