fix error where empty line causes server error

This commit is contained in:
Reinier Balt 2011-01-24 23:05:31 +01:00
parent 30983b6658
commit bf5e378301
2 changed files with 33 additions and 12 deletions

View file

@ -162,17 +162,19 @@ class TodosController < ApplicationController
@todos = [] @todos = []
params[:todo][:multiple_todos].split("\n").map do |line| params[:todo][:multiple_todos].split("\n").map do |line|
@todo = current_user.todos.build( unless line.blank?
:description => line) @todo = current_user.todos.build(
@todo.project_id = @project_id :description => line)
@todo.context_id = @context_id @todo.project_id = @project_id
@saved = @todo.save @todo.context_id = @context_id
unless (@saved == false) || tag_list.blank? @saved = @todo.save
@todo.tag_with(tag_list) unless (@saved == false) || tag_list.blank?
@todo.tags.reload @todo.tag_with(tag_list)
@todo.tags.reload
end
@todos << @todo
@not_done_todos << @todo if @new_context_created
end end
@todos << @todo
@not_done_todos << @todo if @new_context_created
end end
respond_to do |format| respond_to do |format|

View file

@ -186,6 +186,25 @@ Feature: Add new next action from every page
Scenario: Adding a dependency to a todo updated the successor Scenario: Adding a dependency to a todo updated the successor
Given this is a pending scenario Given this is a pending scenario
@selenium
Scenario: I can add multiple todos in a new project and a new context
When I go to the home page
And I follow "Add multiple next actions"
And I fill the multiple actions form with "", "a next project", "@anywhere", "new tag"
And I submit the new multiple actions form with
"""
a
b
c
"""
Then I should see "@anywhere"
And I should see "a"
And I should see "b"
And I should see "c"
@selenium @selenium
Scenario: I need to fill in at least one description and a context Scenario: I need to fill in at least one description and a context
When I go to the home page When I go to the home page