fixes #786 where timezone handling of RoR screwed the algorithm to find the last sunday of march in 2009

Fix is a bit of a hack, see #786 for futher explanation.
This commit is contained in:
Reinier Balt 2008-10-22 10:16:31 +02:00
parent c5cff97f3f
commit a3f23c60e4
4 changed files with 74 additions and 6 deletions

View file

@ -79,7 +79,7 @@ class RecurringTodosControllerTest < ActionController::TestCase
recurring_todo_1 = RecurringTodo.find(1)
assert recurring_todo_1.completed?
# remove remaining todo
# remove remaining todo
todo = Todo.find_by_recurring_todo_id(1)
todo.recurring_todo_id = 2
todo.save
@ -124,5 +124,60 @@ class RecurringTodosControllerTest < ActionController::TestCase
# show_from should be nil since now+4.days-10.days is in the past
assert_equal nil, new_todo.show_from
end
def test_last_sunday_of_march
# this test is a duplicate of the unit test. Only this test covers the
# codepath in the controllers
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"=>"new recurring pattern",
"end_date" => "",
"ends_on" => "no_end_date",
"monthly_day_of_week" => "1",
"monthly_every_x_day" => "22",
"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"=>"0",
"recurring_target"=>"due_date",
"start_from"=>"",
"weekly_every_x_week"=>"1",
"weekly_return_monday"=>"w",
"yearly_day_of_week"=>"0",
"yearly_every_x_day"=>"22",
"yearly_every_xth_day"=>"5",
"yearly_month_of_year2"=>"3",
"yearly_month_of_year"=>"10",
"yearly_selector"=>"yearly_every_xth_day"
},
"tag_list"=>"one, two, three, four"
# check new recurring todo added
assert_equal orig_rt_count+1, RecurringTodo.count
# check new todo added
assert_equal orig_todo_count+1, Todo.count
# find the newly created todo
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
end
end