diff --git a/app/controllers/recurring_todos_controller.rb b/app/controllers/recurring_todos_controller.rb index a15f6922..8fe403b9 100644 --- a/app/controllers/recurring_todos_controller.rb +++ b/app/controllers/recurring_todos_controller.rb @@ -70,6 +70,7 @@ class RecurringTodosController < ApplicationController @down_count = current_user.recurring_todos.active.count @new_recurring_todo = RecurringTodo.new else + @recurring_todo = builder.recurring_todo @status_message = t('todos.error_saving_recurring') end diff --git a/app/models/recurring_todos/monthly_recurring_todos_builder.rb b/app/models/recurring_todos/monthly_recurring_todos_builder.rb index a70cd257..df88b597 100644 --- a/app/models/recurring_todos/monthly_recurring_todos_builder.rb +++ b/app/models/recurring_todos/monthly_recurring_todos_builder.rb @@ -1,6 +1,7 @@ module RecurringTodos class MonthlyRecurringTodosBuilder < AbstractRecurringTodosBuilder + attr_reader :recurring_todo def initialize(user, attributes) super(user, attributes, MonthlyRepeatPattern) @@ -42,4 +43,4 @@ module RecurringTodos end -end \ No newline at end of file +end diff --git a/app/models/recurring_todos/weekly_recurring_todos_builder.rb b/app/models/recurring_todos/weekly_recurring_todos_builder.rb index 8a5254ca..3ff60296 100644 --- a/app/models/recurring_todos/weekly_recurring_todos_builder.rb +++ b/app/models/recurring_todos/weekly_recurring_todos_builder.rb @@ -1,6 +1,7 @@ module RecurringTodos class WeeklyRecurringTodosBuilder < AbstractRecurringTodosBuilder + attr_reader :recurring_todo def initialize(user, attributes) super(user, attributes, WeeklyRepeatPattern) @@ -39,4 +40,4 @@ module RecurringTodos end -end \ No newline at end of file +end diff --git a/app/models/recurring_todos/yearly_recurring_todos_builder.rb b/app/models/recurring_todos/yearly_recurring_todos_builder.rb index 091509d6..f4c795f8 100644 --- a/app/models/recurring_todos/yearly_recurring_todos_builder.rb +++ b/app/models/recurring_todos/yearly_recurring_todos_builder.rb @@ -1,6 +1,7 @@ module RecurringTodos class YearlyRecurringTodosBuilder < AbstractRecurringTodosBuilder + attr_reader :recurring_todo def initialize(user, attributes) super(user, attributes, YearlyRepeatPattern) @@ -41,4 +42,4 @@ module RecurringTodos end -end \ No newline at end of file +end diff --git a/test/controllers/recurring_todos_controller_test.rb b/test/controllers/recurring_todos_controller_test.rb index e58fe562..c9c2bce7 100644 --- a/test/controllers/recurring_todos_controller_test.rb +++ b/test/controllers/recurring_todos_controller_test.rb @@ -70,6 +70,54 @@ class RecurringTodosControllerTest < ActionController::TestCase assert_equal orig_todo_count+1, Todo.count end + def test_invalid_recurring_todo + login_as(:admin_user) + orig_rt_count = RecurringTodo.count + orig_todo_count = Todo.count + put :create, + "context_name"=>"library", + "project_name"=>"Build a working time machine", + "recurring_todo" => + { + "daily_every_x_days"=>"1", + "daily_selector"=>"daily_every_x_day", + "description"=>"", + "end_date" => "31/08/2010", + "ends_on" => "ends_on_end_date", + "monthly_day_of_week" => "1", + "monthly_every_x_day" => "18", + "monthly_every_x_month2" => "1", + "monthly_every_x_month" => "1", + "monthly_every_xth_day"=>"1", + "monthly_selector"=>"monthly_every_x_day", + "notes"=>"with some notes", + "number_of_occurences" => "", + "recurring_period"=>"yearly", + "recurring_show_days_before"=>"10", + "recurring_target"=>"due_date", + "recurring_show_always" => "1", + "start_from"=>"18/08/2008", + "weekly_every_x_week"=>"1", + "weekly_return_monday"=>"m", + "yearly_day_of_week"=>"1", + "yearly_every_x_day"=>"8", + "yearly_every_xth_day"=>"1", + "yearly_month_of_year2"=>"8", + "yearly_month_of_year"=>"6", + "yearly_selector"=>"yearly_every_x_day" + }, + "tag_list"=>"one, two, three, four", :format => :js + + # check no new recurring todo added + assert_equal orig_rt_count, RecurringTodo.count + # check no new todo added + assert_equal orig_todo_count, Todo.count + # check error message + errors = assigns(:recurring_todo).errors + assert_equal 1, errors.size + assert_equal errors.get(:description), ["can't be blank"] + end + def test_new_recurring_todo_handles_attribs_outside_rec_todo login_as(:admin_user)