]> git.openstreetmap.org Git - rails.git/commitdiff
Reject note comments with no text
authorTom Hughes <tom@compton.nu>
Tue, 5 Feb 2013 18:46:41 +0000 (18:46 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 5 Feb 2013 18:46:41 +0000 (18:46 +0000)
app/controllers/notes_controller.rb
test/functional/notes_controller_test.rb

index 0544f8705a527af9379c2368cfdb6cf2455eacc0..e470bdbea3dd0599c69e43ca110411a01fa27125 100644 (file)
@@ -84,7 +84,7 @@ class NotesController < ApplicationController
   def comment
     # Check the arguments are sane
     raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
-    raise OSM::APIBadUserInput.new("No text was given") unless params[:text]
+    raise OSM::APIBadUserInput.new("No text was given") if params[:text].blank?
 
     # Extract the arguments
     id = params[:id].to_i
index 6e6a3c17c22f436d03a14371e39166b3035d7873..3d12d151f8c78c5a31260ae8d9daa6904adb7ad6 100644 (file)
@@ -227,6 +227,11 @@ class NotesControllerTest < ActionController::TestCase
     end
     assert_response :bad_request
 
+    assert_no_difference('NoteComment.count') do
+      post :comment, {:id => notes(:open_note_with_comment).id, :text => ""}
+    end
+    assert_response :bad_request
+
     assert_no_difference('NoteComment.count') do
       post :comment, {:id => 12345, :text => "This is an additional comment"}
     end