]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/diary_comments_controller_test.rb
Make setLatLng a private function
[rails.git] / test / controllers / diary_comments_controller_test.rb
index 2ebf52d16d4bfec427eda22530afacac11b551ae..a06565aa1ca2740a6696aeffe5413062a853297f 100644 (file)
@@ -13,15 +13,15 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest
       { :controller => "diary_comments", :action => "index", :display_name => "username" }
     )
     assert_routing(
       { :controller => "diary_comments", :action => "index", :display_name => "username" }
     )
     assert_routing(
-      { :path => "/user/username/diary/1/newcomment", :method => :post },
+      { :path => "/user/username/diary/1/comments", :method => :post },
       { :controller => "diary_comments", :action => "create", :display_name => "username", :id => "1" }
     )
     assert_routing(
       { :controller => "diary_comments", :action => "create", :display_name => "username", :id => "1" }
     )
     assert_routing(
-      { :path => "/user/username/diary/1/hidecomment/2", :method => :post },
+      { :path => "/user/username/diary/1/comments/2/hide", :method => :post },
       { :controller => "diary_comments", :action => "hide", :display_name => "username", :id => "1", :comment => "2" }
     )
     assert_routing(
       { :controller => "diary_comments", :action => "hide", :display_name => "username", :id => "1", :comment => "2" }
     )
     assert_routing(
-      { :path => "/user/username/diary/1/unhidecomment/2", :method => :post },
+      { :path => "/user/username/diary/1/comments/2/unhide", :method => :post },
       { :controller => "diary_comments", :action => "unhide", :display_name => "username", :id => "1", :comment => "2" }
     )
 
       { :controller => "diary_comments", :action => "unhide", :display_name => "username", :id => "1", :comment => "2" }
     )
 
@@ -115,14 +115,14 @@ class DiaryCommentsControllerTest < ActionDispatch::IntegrationTest
         end
       end
     end
         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
     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
     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
         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
     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
     assert_equal entry.id, comment.diary_entry_id
     assert_equal other_user.id, comment.user_id
     assert_equal spammy_text, comment.body