]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/notes_controller_test.rb
Use only_path instead of setting an explicit host
[rails.git] / test / controllers / notes_controller_test.rb
index e846bbd6aba21e1386bf29b75a2cacab564adb28..ab63bbca2408a3938c9f4d58d9f6744c2a36c489 100644 (file)
@@ -3,6 +3,12 @@ require "test_helper"
 class NotesControllerTest < ActionController::TestCase
   fixtures :users, :user_roles
 
+  def setup
+    # Stub nominatim response for note locations
+    stub_request(:get, %r{^http://nominatim\.openstreetmap\.org/reverse\?})
+      .to_return(:status => 404)
+  end
+
   ##
   # test all routes which lead to this controller
   def test_routes
@@ -245,8 +251,8 @@ class NotesControllerTest < ActionController::TestCase
 
     # Ensure that emails are sent to users
     note_with_comments_by_users = create(:note) do |note|
-      create(:note_comment, :note => note, :author_id => users(:normal_user).id)
-      create(:note_comment, :note => note, :author_id => users(:second_public_user).id)
+      create(:note_comment, :note => note, :author => users(:normal_user))
+      create(:note_comment, :note => note, :author => users(:second_public_user))
     end
     assert_difference "NoteComment.count", 1 do
       assert_difference "ActionMailer::Base.deliveries.size", 2 do
@@ -539,7 +545,7 @@ class NotesControllerTest < ActionController::TestCase
         assert_select "time", :count => 1
         assert_select "name", "Note: #{open_note.id}"
         assert_select "desc", :count => 1
-        assert_select "link[href='http://www.openstreetmap.org/note/#{open_note.id}']", :count => 1
+        assert_select "link[href='http://test.host/note/#{open_note.id}']", :count => 1
         assert_select "extensions", :count => 1 do
           assert_select "id", open_note.id.to_s
           assert_select "url", note_url(open_note, :format => "gpx")
@@ -934,13 +940,13 @@ class NotesControllerTest < ActionController::TestCase
 
   def test_mine_success
     create(:note) do |note|
-      create(:note_comment, :note => note, :author_id => users(:normal_user).id)
+      create(:note_comment, :note => note, :author => users(:normal_user))
     end
     create(:note) do |note|
-      create(:note_comment, :note => note, :author_id => users(:second_public_user).id)
+      create(:note_comment, :note => note, :author => users(:second_public_user))
     end
     create(:note, :status => "hidden") do |note|
-      create(:note_comment, :note => note, :author_id => users(:second_public_user).id)
+      create(:note_comment, :note => note, :author => users(:second_public_user))
     end
 
     # Note that the table rows include a header row