From d1aa084d2804137d2c1d4bf04f7fd5fe319d6772 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 5 Feb 2013 18:46:41 +0000 Subject: [PATCH] Reject note comments with no text --- app/controllers/notes_controller.rb | 2 +- test/functional/notes_controller_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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 -- 2.43.2