]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/diary_comments_controller_test.rb
Redirect to newly created diary comment
[rails.git] / test / controllers / diary_comments_controller_test.rb
index fa978d606baa57ee9871eb1251fbb4f15cd99f44..a06565aa1ca2740a6696aeffe5413062a853297f 100644 (file)
@@ -115,14 +115,14 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest
         end
       end
     end
-    assert_redirected_to diary_entry_path(entry.user, entry)
+    comment = DiaryComment.last
+    assert_redirected_to diary_entry_path(entry.user, entry, :anchor => "comment#{comment.id}")
     email = ActionMailer::Base.deliveries.first
     assert_equal [user.email], email.to
     assert_equal "[OpenStreetMap] #{other_user.display_name} commented on a diary entry", email.subject
     assert_match(/New comment/, email.text_part.decoded)
     assert_match(/New comment/, email.html_part.decoded)
     ActionMailer::Base.deliveries.clear
-    comment = DiaryComment.order(:id).last
     assert_equal entry.id, comment.diary_entry_id
     assert_equal other_user.id, comment.user_id
     assert_equal "New comment", comment.body
@@ -157,14 +157,14 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest
         end
       end
     end
-    assert_redirected_to diary_entry_path(entry.user, entry)
+    comment = DiaryComment.last
+    assert_redirected_to diary_entry_path(entry.user, entry, :anchor => "comment#{comment.id}")
     email = ActionMailer::Base.deliveries.first
     assert_equal [user.email], email.to
     assert_equal "[OpenStreetMap] #{other_user.display_name} commented on a diary entry", email.subject
     assert_match %r{http://example.com/spam}, email.text_part.decoded
     assert_match %r{http://example.com/spam}, email.html_part.decoded
     ActionMailer::Base.deliveries.clear
-    comment = DiaryComment.order(:id).last
     assert_equal entry.id, comment.diary_entry_id
     assert_equal other_user.id, comment.user_id
     assert_equal spammy_text, comment.body