Reject attempts to create notes with no comment text

This commit is contained in:
Tom Hughes 2013-02-05 21:54:03 +00:00
parent 68044c6054
commit eed9de5483
2 changed files with 8 additions and 1 deletions

View 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]
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

View file

@ -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"}