]> git.openstreetmap.org Git - rails.git/commitdiff
Avoid relying on the order in which emails are sent
authorTom Hughes <tom@compton.nu>
Thu, 5 Mar 2015 00:16:26 +0000 (00:16 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 5 Mar 2015 00:16:26 +0000 (00:16 +0000)
.rubocop_todo.yml
test/controllers/changeset_controller_test.rb
test/controllers/notes_controller_test.rb

index a993d5fff1a3968fbece6a2df3218abded4f2204..5f2a84fc9dee64fc04abef7746184b93b82a6a9b 100644 (file)
@@ -28,7 +28,7 @@ Lint/ParenthesesAsGroupedExpression:
 
 # Offense count: 542
 Metrics/AbcSize:
 
 # Offense count: 542
 Metrics/AbcSize:
-  Max: 270
+  Max: 280
 
 # Offense count: 12
 Metrics/BlockNesting:
 
 # Offense count: 12
 Metrics/BlockNesting:
index 148e54767d486ad7918f442df9d9277aa3689e7a..1be10ec2a3c9440a3c17a886bbb77e1e6f4c7e92 100644 (file)
@@ -1914,15 +1914,15 @@ EOF
     end
     assert_response :success
 
     end
     assert_response :success
 
-    email = ActionMailer::Base.deliveries.first
+    email = ActionMailer::Base.deliveries.find { |e| e.to.first == "test@openstreetmap.org" }
+    assert_not_nil email
     assert_equal 1, email.to.length
     assert_equal "[OpenStreetMap] pulibc_test2 has commented on one of your changesets", email.subject
     assert_equal 1, email.to.length
     assert_equal "[OpenStreetMap] pulibc_test2 has commented on one of your changesets", email.subject
-    assert_equal "test@openstreetmap.org", email.to.first
 
 
-    email = ActionMailer::Base.deliveries.second
+    email = ActionMailer::Base.deliveries.find { |e| e.to.first == "test@example.com" }
+    assert_not_nil email
     assert_equal 1, email.to.length
     assert_equal "[OpenStreetMap] pulibc_test2 has commented on a changeset you are interested in", email.subject
     assert_equal 1, email.to.length
     assert_equal "[OpenStreetMap] pulibc_test2 has commented on a changeset you are interested in", email.subject
-    assert_equal "test@example.com", email.to.first
 
     ActionMailer::Base.deliveries.clear
   end
 
     ActionMailer::Base.deliveries.clear
   end
index 16ad623e4e2e302509a46390d1fc37b3f834bc3d..c80a95e5a450f88e49fadc9a5fe0db9ebd5b2b4a 100644 (file)
@@ -258,15 +258,15 @@ class NotesControllerTest < ActionController::TestCase
     assert_equal "This is an additional comment", js["properties"]["comments"].last["text"]
     assert_nil js["properties"]["comments"].last["user"]
 
     assert_equal "This is an additional comment", js["properties"]["comments"].last["text"]
     assert_nil js["properties"]["comments"].last["user"]
 
-    email = ActionMailer::Base.deliveries.first
+    email = ActionMailer::Base.deliveries.find { |e| e.to.first == "test@openstreetmap.org" }
+    assert_not_nil email
     assert_equal 1, email.to.length
     assert_equal "[OpenStreetMap] An anonymous user has commented on one of your notes", email.subject
     assert_equal 1, email.to.length
     assert_equal "[OpenStreetMap] An anonymous user has commented on one of your notes", email.subject
-    assert_equal "test@openstreetmap.org", email.to.first
 
 
-    email = ActionMailer::Base.deliveries.second
+    email = ActionMailer::Base.deliveries.find { |e| e.to.first == "public@OpenStreetMap.org" }
+    assert_not_nil email
     assert_equal 1, email.to.length
     assert_equal "[OpenStreetMap] An anonymous user has commented on a note you are interested in", email.subject
     assert_equal 1, email.to.length
     assert_equal "[OpenStreetMap] An anonymous user has commented on a note you are interested in", email.subject
-    assert_equal "public@OpenStreetMap.org", email.to.first
 
     get :show, :id => notes(:note_with_comments_by_users).id, :format => "json"
     assert_response :success
 
     get :show, :id => notes(:note_with_comments_by_users).id, :format => "json"
     assert_response :success
@@ -300,15 +300,16 @@ class NotesControllerTest < ActionController::TestCase
     assert_equal "This is an additional comment", js["properties"]["comments"].last["text"]
     assert_equal "test2", js["properties"]["comments"].last["user"]
 
     assert_equal "This is an additional comment", js["properties"]["comments"].last["text"]
     assert_equal "test2", js["properties"]["comments"].last["user"]
 
-    email = ActionMailer::Base.deliveries.first
+    email = ActionMailer::Base.deliveries.find { |e| e.to.first == "test@openstreetmap.org" }
+    assert_not_nil email
     assert_equal 1, email.to.length
     assert_equal "[OpenStreetMap] test2 has commented on one of your notes", email.subject
     assert_equal "test@openstreetmap.org", email.to.first
 
     assert_equal 1, email.to.length
     assert_equal "[OpenStreetMap] test2 has commented on one of your notes", email.subject
     assert_equal "test@openstreetmap.org", email.to.first
 
-    email = ActionMailer::Base.deliveries.second
+    email = ActionMailer::Base.deliveries.find { |e| e.to.first == "public@OpenStreetMap.org" }
+    assert_not_nil email
     assert_equal 1, email.to.length
     assert_equal "[OpenStreetMap] test2 has commented on a note you are interested in", email.subject
     assert_equal 1, email.to.length
     assert_equal "[OpenStreetMap] test2 has commented on a note you are interested in", email.subject
-    assert_equal "public@OpenStreetMap.org", email.to.first
 
     get :show, :id => notes(:note_with_comments_by_users).id, :format => "json"
     assert_response :success
 
     get :show, :id => notes(:note_with_comments_by_users).id, :format => "json"
     assert_response :success