mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-27 04:18:49 +01:00
fix false test error using timecop
This commit is contained in:
parent
13869edf8e
commit
f42a5d3bdd
1 changed files with 48 additions and 45 deletions
|
|
@ -126,56 +126,59 @@ class RecurringTodosControllerTest < ActionController::TestCase
|
|||
# this test is a duplicate of the unit test. Only this test covers the
|
||||
# codepath in the controllers
|
||||
|
||||
login_as(:admin_user)
|
||||
Timecop.travel(Time.local(2012,1,1)) do
|
||||
|
||||
orig_rt_count = RecurringTodo.count
|
||||
orig_todo_count = Todo.count
|
||||
login_as(:admin_user)
|
||||
|
||||
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",
|
||||
"recurring_show_always" => "1",
|
||||
"start_from"=>"1/10/2012", # adjust after 2012
|
||||
"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"
|
||||
orig_rt_count = RecurringTodo.count
|
||||
orig_todo_count = Todo.count
|
||||
|
||||
# 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
|
||||
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",
|
||||
"recurring_show_always" => "1",
|
||||
"start_from"=>"1/10/2012", # adjust after 2012
|
||||
"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"
|
||||
|
||||
# find the newly created todo
|
||||
new_todo = Todo.find_by_description("new recurring pattern")
|
||||
assert !new_todo.nil?
|
||||
# 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
|
||||
|
||||
# the date should be 31 march 2013
|
||||
assert_equal Time.zone.local(2013,3,31), new_todo.due
|
||||
# find the newly created todo
|
||||
new_todo = Todo.find_by_description("new recurring pattern")
|
||||
assert !new_todo.nil?
|
||||
|
||||
# the date should be 31 march 2013
|
||||
assert_equal Time.zone.local(2013,3,31), new_todo.due
|
||||
end
|
||||
end
|
||||
|
||||
def test_recurring_todo_with_due_date_and_show_always
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue