From c450182a2108b0e3b0425917496a9ef767f12415 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Wed, 1 Apr 2009 13:51:36 +0200 Subject: [PATCH] fix for the two issues in #852 * the end date is prefilled with an incorrect formatted date * if the radio for ends_on is not selected, but a date is entered, tracks incorrectly behaves as if ends_on was checked --- app/models/recurring_todo.rb | 2 +- app/views/recurring_todos/_recurring_todo_form.erb | 2 +- test/functional/recurring_todos_controller_test.rb | 6 +++--- test/unit/recurring_todo_test.rb | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/models/recurring_todo.rb b/app/models/recurring_todo.rb index f8f22526..cb5f4173 100644 --- a/app/models/recurring_todo.rb +++ b/app/models/recurring_todo.rb @@ -596,7 +596,7 @@ class RecurringTodo < ActiveRecord::Base unless self.number_of_occurences.nil? return self.occurences_count < self.number_of_occurences else - if self.end_date.nil? + if self.end_date.nil? || self.ends_on == 'no_end_date' return true else case self.target diff --git a/app/views/recurring_todos/_recurring_todo_form.erb b/app/views/recurring_todos/_recurring_todo_form.erb index 386d2c80..177850a5 100644 --- a/app/views/recurring_todos/_recurring_todo_form.erb +++ b/app/views/recurring_todos/_recurring_todo_form.erb @@ -78,7 +78,7 @@
<%= radio_button_tag('recurring_todo[ends_on]', 'no_end_date', true)%> No end date
<%= radio_button_tag('recurring_todo[ends_on]', 'ends_on_number_of_times')%> Ends after <%= text_field( :recurring_todo, :number_of_occurences, "size" => 3, "tabindex" => 7) %> times
- <%= radio_button_tag('recurring_todo[ends_on]', 'ends_on_end_date')%> Ends on <%= text_field(:recurring_todo, :end_date, "size" => 12, "class" => "Date", "onfocus" => "Calendar.setup", "tabindex" => 8, "autocomplete" => "off") %>
+ <%= radio_button_tag('recurring_todo[ends_on]', 'ends_on_end_date')%> Ends on <%= text_field(:recurring_todo, :end_date, "size" => 12, "class" => "Date", "onfocus" => "Calendar.setup", "tabindex" => 8, "autocomplete" => "off", "value" => "") %>

diff --git a/test/functional/recurring_todos_controller_test.rb b/test/functional/recurring_todos_controller_test.rb index 2bd67e67..7b0bd86d 100644 --- a/test/functional/recurring_todos_controller_test.rb +++ b/test/functional/recurring_todos_controller_test.rb @@ -155,7 +155,7 @@ class RecurringTodosControllerTest < ActionController::TestCase "recurring_period"=>"yearly", "recurring_show_days_before"=>"0", "recurring_target"=>"due_date", - "start_from"=>"", + "start_from"=>"1/10/2012", # adjust after 2012 "weekly_every_x_week"=>"1", "weekly_return_monday"=>"w", "yearly_day_of_week"=>"0", @@ -176,8 +176,8 @@ class RecurringTodosControllerTest < ActionController::TestCase new_todo = Todo.find_by_description("new recurring pattern") assert !new_todo.nil? - # the date should be 29 march 2009 - assert_equal Time.zone.local(2009,3,29), new_todo.due + # the date should be 31 march 2013 + assert_equal Time.zone.local(2013,3,31), new_todo.due end end diff --git a/test/unit/recurring_todo_test.rb b/test/unit/recurring_todo_test.rb index b223b2a1..9498216b 100644 --- a/test/unit/recurring_todo_test.rb +++ b/test/unit/recurring_todo_test.rb @@ -81,6 +81,7 @@ class RecurringTodoTest < Test::Rails::TestCase assert_equal true, @every_day.has_next_todo(@in_three_days) assert_equal true, @every_day.has_next_todo(@in_four_days) @every_day.end_date = @in_four_days + @every_day.ends_on = 'ends_on_end_date' assert_equal false, @every_day.has_next_todo(@in_four_days) end