]> git.openstreetmap.org Git - rails.git/commitdiff
Reject attempts to create notes with no comment text
authorTom Hughes <tom@compton.nu>
Tue, 5 Feb 2013 21:54:03 +0000 (21:54 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 5 Feb 2013 21:54:03 +0000 (21:54 +0000)
app/controllers/notes_controller.rb
test/functional/notes_controller_test.rb

index e470bdbea3dd0599c69e43ca110411a01fa27125..8a00296555671f7ce4ecb3ff99ca076cbf3c0a69 100644 (file)
@@ -52,7 +52,7 @@ class NotesController < ApplicationController
     # Check the arguments are sane
     raise OSM::APIBadUserInput.new("No lat was given") unless params[:lat]
     raise OSM::APIBadUserInput.new("No lon was given") unless params[:lon]
     # Check the arguments are sane
     raise OSM::APIBadUserInput.new("No lat was given") unless params[:lat]
     raise OSM::APIBadUserInput.new("No lon was given") unless params[:lon]
-    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
     lon = params[:lon].to_f
 
     # Extract the arguments
     lon = params[:lon].to_f
index 3d12d151f8c78c5a31260ae8d9daa6904adb7ad6..2b880943c39dc27930a7db47a8201e6df74e68f9 100644 (file)
@@ -173,6 +173,13 @@ class NotesControllerTest < ActionController::TestCase
     end
     assert_response :bad_request
 
     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 => ""}
+      end
+    end
+    assert_response :bad_request
+
     assert_no_difference('Note.count') do
       assert_no_difference('NoteComment.count') do
         post :create, {:lat => -100.0, :lon => -1.0, :text => "This is a comment"}
     assert_no_difference('Note.count') do
       assert_no_difference('NoteComment.count') do
         post :create, {:lat => -100.0, :lon => -1.0, :text => "This is a comment"}