]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/messages_controller_test.rb
Use deliver_later for all email sending
[rails.git] / test / controllers / messages_controller_test.rb
index 0b3a59b395310709e35e7199dc9eccde82edcae9..8e4d5eeb27fd0f4cd062c2dc7627fa5dea2997cd 100644 (file)
@@ -83,9 +83,11 @@ class MessagesControllerTest < ActionController::TestCase
     # Check that we can't send a message from a GET request
     assert_difference "ActionMailer::Base.deliveries.size", 0 do
       assert_difference "Message.count", 0 do
-        get :new,
-            :params => { :display_name => recipient_user.display_name,
-                         :message => { :title => "Test Message", :body => "Test message body" } }
+        perform_enqueued_jobs do
+          get :new,
+              :params => { :display_name => recipient_user.display_name,
+                           :message => { :title => "Test Message", :body => "Test message body" } }
+        end
       end
     end
     assert_response :success
@@ -112,9 +114,11 @@ class MessagesControllerTest < ActionController::TestCase
     # Check that the subject is preserved over errors
     assert_difference "ActionMailer::Base.deliveries.size", 0 do
       assert_difference "Message.count", 0 do
-        post :new,
-             :params => { :display_name => recipient_user.display_name,
-                          :message => { :title => "Test Message", :body => "" } }
+        perform_enqueued_jobs do
+          post :new,
+               :params => { :display_name => recipient_user.display_name,
+                            :message => { :title => "Test Message", :body => "" } }
+        end
       end
     end
     assert_response :success
@@ -141,9 +145,11 @@ class MessagesControllerTest < ActionController::TestCase
     # Check that the body text is preserved over errors
     assert_difference "ActionMailer::Base.deliveries.size", 0 do
       assert_difference "Message.count", 0 do
-        post :new,
-             :params => { :display_name => recipient_user.display_name,
-                          :message => { :title => "", :body => "Test message body" } }
+        perform_enqueued_jobs do
+          post :new,
+               :params => { :display_name => recipient_user.display_name,
+                            :message => { :title => "", :body => "Test message body" } }
+        end
       end
     end
     assert_response :success
@@ -170,9 +176,11 @@ class MessagesControllerTest < ActionController::TestCase
     # Check that sending a message works
     assert_difference "ActionMailer::Base.deliveries.size", 1 do
       assert_difference "Message.count", 1 do
-        post :create,
-             :params => { :display_name => recipient_user.display_name,
-                          :message => { :title => "Test Message", :body => "Test message body" } }
+        perform_enqueued_jobs do
+          post :create,
+               :params => { :display_name => recipient_user.display_name,
+                            :message => { :title => "Test Message", :body => "Test message body" } }
+        end
       end
     end
     assert_redirected_to inbox_messages_path
@@ -211,12 +219,14 @@ class MessagesControllerTest < ActionController::TestCase
     assert_no_difference "ActionMailer::Base.deliveries.size" do
       assert_no_difference "Message.count" do
         with_message_limit(0) do
-          post :create,
-               :params => { :display_name => recipient_user.display_name,
-                            :message => { :title => "Test Message", :body => "Test message body" } }
-          assert_response :success
-          assert_template "new"
-          assert_select ".error", /wait a while/
+          perform_enqueued_jobs do
+            post :create,
+                 :params => { :display_name => recipient_user.display_name,
+                              :message => { :title => "Test Message", :body => "Test message body" } }
+            assert_response :success
+            assert_template "new"
+            assert_select ".error", /wait a while/
+          end
         end
       end
     end