From eed9de548363fc705af1bab13c8d5a06cdd62a11 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 5 Feb 2013 21:54:03 +0000 Subject: [PATCH 1/1] Reject attempts to create notes with no comment text --- app/controllers/notes_controller.rb | 2 +- test/functional/notes_controller_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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"} -- 2.43.2