From 77e8a16a153752b919a9153c1c9ded9834d387f7 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 5 Mar 2015 00:16:26 +0000 Subject: [PATCH 1/1] Avoid relying on the order in which emails are sent --- .rubocop_todo.yml | 2 +- test/controllers/changeset_controller_test.rb | 8 ++++---- test/controllers/notes_controller_test.rb | 15 ++++++++------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a993d5fff..5f2a84fc9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -28,7 +28,7 @@ Lint/ParenthesesAsGroupedExpression: # Offense count: 542 Metrics/AbcSize: - Max: 270 + Max: 280 # Offense count: 12 Metrics/BlockNesting: diff --git a/test/controllers/changeset_controller_test.rb b/test/controllers/changeset_controller_test.rb index 148e54767..1be10ec2a 100644 --- a/test/controllers/changeset_controller_test.rb +++ b/test/controllers/changeset_controller_test.rb @@ -1914,15 +1914,15 @@ EOF 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 "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 "test@example.com", email.to.first ActionMailer::Base.deliveries.clear end diff --git a/test/controllers/notes_controller_test.rb b/test/controllers/notes_controller_test.rb index 16ad623e4..c80a95e5a 100644 --- a/test/controllers/notes_controller_test.rb +++ b/test/controllers/notes_controller_test.rb @@ -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"] - 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 "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 "public@OpenStreetMap.org", email.to.first 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"] - 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 - 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 "public@OpenStreetMap.org", email.to.first get :show, :id => notes(:note_with_comments_by_users).id, :format => "json" assert_response :success -- 2.43.2