From: Tom Hughes Date: Tue, 5 Feb 2013 21:54:03 +0000 (+0000) Subject: Reject attempts to create notes with no comment text X-Git-Tag: live~5052^2~18 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/eed9de548363fc705af1bab13c8d5a06cdd62a11 Reject attempts to create notes with no comment text --- diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index e470bdbea..8a0029655 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -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] - 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 diff --git a/test/functional/notes_controller_test.rb b/test/functional/notes_controller_test.rb index 3d12d151f..2b880943c 100644 --- a/test/functional/notes_controller_test.rb +++ b/test/functional/notes_controller_test.rb @@ -173,6 +173,13 @@ class NotesControllerTest < ActionController::TestCase 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"}