]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/notes_controller_test.rb
Merge remote-tracking branch 'openstreetmap/pull/1553'
[rails.git] / test / controllers / notes_controller_test.rb
index 4bb106b170dd0ac58669b5fed03b030ecc0106e1..3ee283f4a7e7a656b7710963594dac05c46aca03 100644 (file)
@@ -215,6 +215,13 @@ class NotesControllerTest < ActionController::TestCase
       end
     end
     assert_response :bad_request
+
+    assert_no_difference "Note.count" do
+      assert_no_difference "NoteComment.count" do
+        post :create, :lat => -1.0, :lon => -1.0, :text => "x\u0000y"
+      end
+    end
+    assert_response :bad_request
   end
 
   def test_comment_success
@@ -248,9 +255,9 @@ class NotesControllerTest < ActionController::TestCase
     assert_nil js["properties"]["comments"].last["user"]
 
     # Ensure that emails are sent to users
-    first_user = create(:normal_user)
-    second_user = create(:normal_user)
-    third_user = create(:normal_user)
+    first_user = create(:user)
+    second_user = create(:user)
+    third_user = create(:user)
 
     note_with_comments_by_users = create(:note) do |note|
       create(:note_comment, :note => note, :author => first_user)
@@ -376,11 +383,16 @@ class NotesControllerTest < ActionController::TestCase
       post :comment, :id => closed_note_with_comment.id, :text => "This is an additional comment"
     end
     assert_response :conflict
+
+    assert_no_difference "NoteComment.count" do
+      post :comment, :id => open_note_with_comment.id, :text => "x\u0000y"
+    end
+    assert_response :bad_request
   end
 
   def test_close_success
     open_note_with_comment = create(:note_with_comments)
-    user = create(:normal_user)
+    user = create(:user)
 
     post :close, :id => open_note_with_comment.id, :text => "This is a close comment", :format => "json"
     assert_response :unauthorized
@@ -416,7 +428,7 @@ class NotesControllerTest < ActionController::TestCase
     post :close
     assert_response :unauthorized
 
-    basic_authorization(create(:normal_user).email, "test")
+    basic_authorization(create(:user).email, "test")
 
     post :close
     assert_response :bad_request
@@ -437,7 +449,7 @@ class NotesControllerTest < ActionController::TestCase
 
   def test_reopen_success
     closed_note_with_comment = create(:note_with_comments, :status => "closed", :closed_at => Time.now)
-    user = create(:normal_user)
+    user = create(:user)
 
     post :reopen, :id => closed_note_with_comment.id, :text => "This is a reopen comment", :format => "json"
     assert_response :unauthorized
@@ -475,7 +487,7 @@ class NotesControllerTest < ActionController::TestCase
     post :reopen, :id => hidden_note_with_comment.id
     assert_response :unauthorized
 
-    basic_authorization(create(:normal_user).email, "test")
+    basic_authorization(create(:user).email, "test")
 
     post :reopen, :id => 12345
     assert_response :not_found
@@ -588,8 +600,8 @@ class NotesControllerTest < ActionController::TestCase
 
   def test_destroy_success
     open_note_with_comment = create(:note_with_comments)
-    user = create(:normal_user)
-    moderator_user = create(:moderator_user, :status => "active")
+    user = create(:user)
+    moderator_user = create(:moderator_user)
 
     delete :destroy, :id => open_note_with_comment.id, :text => "This is a hide comment", :format => "json"
     assert_response :unauthorized
@@ -618,8 +630,8 @@ class NotesControllerTest < ActionController::TestCase
   end
 
   def test_destroy_fail
-    user = create(:normal_user)
-    moderator_user = create(:moderator_user, :status => "active")
+    user = create(:user)
+    moderator_user = create(:moderator_user)
 
     delete :destroy, :id => 12345, :format => "json"
     assert_response :unauthorized
@@ -948,9 +960,9 @@ class NotesControllerTest < ActionController::TestCase
   end
 
   def test_mine_success
-    first_user = create(:normal_user)
-    second_user = create(:normal_user)
-    moderator_user = create(:moderator_user, :status => "active", :terms_seen => true)
+    first_user = create(:user)
+    second_user = create(:user)
+    moderator_user = create(:moderator_user)
 
     create(:note) do |note|
       create(:note_comment, :note => note, :author => first_user)