From: Tom Hughes Date: Tue, 5 Feb 2013 18:46:41 +0000 (+0000) Subject: Reject note comments with no text X-Git-Tag: live~5104^2~23 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/d1aa084d2804137d2c1d4bf04f7fd5fe319d6772?ds=sidebyside Reject note comments with no text --- diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 0544f8705..e470bdbea 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -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 diff --git a/test/functional/notes_controller_test.rb b/test/functional/notes_controller_test.rb index 6e6a3c17c..3d12d151f 100644 --- a/test/functional/notes_controller_test.rb +++ b/test/functional/notes_controller_test.rb @@ -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