diff --git a/Gemfile b/Gemfile index 40da7701..ab4154dd 100644 --- a/Gemfile +++ b/Gemfile @@ -59,7 +59,6 @@ group :test do gem "mocha", :require => false gem "aruba", git: 'https://github.com/cucumber/aruba', :require => false # need 0.5.4 for piping files; 0.5.3 is latest - gem "timecop", "~> 0.6.2" # Note that > 2.14 has problems, see: # https://code.google.com/p/selenium/issues/detail?id=3075 diff --git a/Gemfile.lock b/Gemfile.lock index 545561ec..28505feb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -189,7 +189,6 @@ GEM thor (0.19.1) thread_safe (0.3.3) tilt (1.4.1) - timecop (0.6.3) tolk (1.5.0) safe_yaml (~> 0.8) will_paginate @@ -243,7 +242,6 @@ DEPENDENCIES sqlite3 swf_fu therubyracer - timecop (~> 0.6.2) tolk (>= 1.5.0) uglifier (>= 1.3.0) will_paginate diff --git a/features/step_definitions/generic_steps.rb b/features/step_definitions/generic_steps.rb index 98d4f13f..b48c2ccb 100644 --- a/features/step_definitions/generic_steps.rb +++ b/features/step_definitions/generic_steps.rb @@ -12,7 +12,7 @@ end Given /^the date is "(.*?)"$/ do |date| # remember to tag the scenario with @reset_time to reset this travel - Timecop.travel(date) + travel_to date end Given(/^I have selected the view for group by (project|context)$/) do |grouping| diff --git a/features/support/hooks.rb b/features/support/hooks.rb index db04f79e..2895076c 100644 --- a/features/support/hooks.rb +++ b/features/support/hooks.rb @@ -9,5 +9,5 @@ Before('@aruba') do end After('@reset_time') do - Timecop.return + travel_back end \ No newline at end of file diff --git a/test/controllers/recurring_todos_controller_test.rb b/test/controllers/recurring_todos_controller_test.rb index b8ce950e..9f55e55a 100644 --- a/test/controllers/recurring_todos_controller_test.rb +++ b/test/controllers/recurring_todos_controller_test.rb @@ -183,7 +183,7 @@ class RecurringTodosControllerTest < ActionController::TestCase # this test is a duplicate of the unit test. Only this test covers the # codepath in the controllers - Timecop.travel(Time.local(2012,1,1)) do + travel_to Time.local(2012,1,1) do login_as(:admin_user) @@ -292,7 +292,7 @@ class RecurringTodosControllerTest < ActionController::TestCase end def test_start_on_monthly_rec_todo - Timecop.travel(Time.local(2012,1,1)) do + travel_to Time.local(2012,1,1) do login_as(:admin_user) diff --git a/test/controllers/stats_controller_test.rb b/test/controllers/stats_controller_test.rb index 20add95c..5f121da9 100644 --- a/test/controllers/stats_controller_test.rb +++ b/test/controllers/stats_controller_test.rb @@ -97,7 +97,7 @@ class StatsControllerTest < ActionController::TestCase end def test_actions_done_last12months_data - Timecop.travel(Time.local(2013, 1, 15)) do + travel_to Time.local(2013, 1, 15) do login_as(:admin_user) @current_user = User.find(users(:admin_user).id) @current_user.todos.delete_all @@ -143,7 +143,7 @@ class StatsControllerTest < ActionController::TestCase end def test_empty_last12months_data - Timecop.travel(Time.local(2013, 1, 15)) do + travel_to Time.local(2013, 1, 15) do login_as(:admin_user) @current_user = User.find(users(:admin_user).id) @current_user.todos.delete_all diff --git a/test/controllers/todos_controller_test.rb b/test/controllers/todos_controller_test.rb index 8540d450..b55730bf 100644 --- a/test/controllers/todos_controller_test.rb +++ b/test/controllers/todos_controller_test.rb @@ -435,7 +435,7 @@ class TodosControllerTest < ActionController::TestCase login_as(:admin_user) # given a todo in the tickler that should be activated - Timecop.travel(2.weeks.ago) do + travel_to 2.weeks.ago do create_todo( description: "tickler", show_from: 1.week.from_now. @@ -715,7 +715,7 @@ class TodosControllerTest < ActionController::TestCase end def test_toggle_check_on_rec_todo_show_from_today - Timecop.travel(2014, 1, 15) do + travel_to Time.zone.local(2014, 1, 15) do login_as(:admin_user) # link todo_1 and recurring_todo_1 diff --git a/test/models/recurring_todos/abstract_repeat_pattern_test.rb b/test/models/recurring_todos/abstract_repeat_pattern_test.rb index d0bcf98b..339c1dac 100644 --- a/test/models/recurring_todos/abstract_repeat_pattern_test.rb +++ b/test/models/recurring_todos/abstract_repeat_pattern_test.rb @@ -101,7 +101,7 @@ module RecurringTodos end def test_determine_start - Timecop.travel(2013,1,1) do + travel_to Time.zone.local(2013,1,1) do rt = create_recurring_todo assert_equal "2013-01-01 00:00:00", rt.send(:determine_start, nil).to_s(:db), "no previous date, use today" assert_equal "2013-01-01 00:00:00", rt.send(:determine_start, nil, 1.day).to_s(:db), "no previous date, use today without offset" diff --git a/test/models/staleness_test.rb b/test/models/staleness_test.rb index 976a8861..ddbff98e 100644 --- a/test/models/staleness_test.rb +++ b/test/models/staleness_test.rb @@ -1,9 +1,10 @@ require_relative '../minimal_test_helper' require_relative '../../lib/staleness' require_relative '../../lib/user_time' -require 'timecop' class StalenessTest < Minitest::Test + include ActiveSupport::Testing::TimeHelpers + FakePrefs = Struct.new(:time_zone) FakeUser = Struct.new(:time) do def prefs @@ -36,11 +37,11 @@ class StalenessTest < Minitest::Test def setup @current_user = FakeUser.new(now) - Timecop.freeze(Time.utc(2013,02,28)) + travel_to Time.utc(2013,02,28) end def teardown - Timecop.return + travel_back end def test_item_with_due_date_is_not_stale_ever diff --git a/test/models/todo_test.rb b/test/models/todo_test.rb index a6ba8c92..3786b417 100644 --- a/test/models/todo_test.rb +++ b/test/models/todo_test.rb @@ -169,7 +169,7 @@ class TodoTest < ActiveSupport::TestCase dates.each do |show_from_date| # setup test case t = @not_completed1 - Timecop.travel(show_from_date - 1.day) do + travel_to show_from_date - 1.day do t.show_from = show_from_date t.save! assert t.deferred? diff --git a/test/models/todos/calendar_test.rb b/test/models/todos/calendar_test.rb index 5148f47c..31442a19 100644 --- a/test/models/todos/calendar_test.rb +++ b/test/models/todos/calendar_test.rb @@ -34,7 +34,7 @@ module Todos def test_due_this_month_at_start_month # should return 1 todo - Timecop.travel(2013,9,1) do + travel_to Time.zone.local(2013,9,1) do due_this_month = create_todo(Time.zone.now.end_of_month) assert_equal [due_this_month], @calendar.due_this_month end @@ -43,7 +43,7 @@ module Todos def test_due_this_month_at_end_month # the todo is due next week and is thus left out for todos due rest # of month (i.e. after next week, but in this month) - Timecop.travel(2013,9,23) do + travel_to Time.zone.local(2013,9,23) do due_this_month = create_todo(Time.zone.now.end_of_month) assert_equal 0, @calendar.due_this_month.size end diff --git a/test/models/todos/done_todos_test.rb b/test/models/todos/done_todos_test.rb index b3b066e4..17a7dcfd 100644 --- a/test/models/todos/done_todos_test.rb +++ b/test/models/todos/done_todos_test.rb @@ -4,7 +4,7 @@ module Todos class DoneTodosTest < ActiveSupport::TestCase def test_completed_period - Timecop.travel(2013,1,23,12,00,00) do # wednesday at 12:00; + travel_to Time.zone.local(2013,1,23,12,00,00) do # wednesday at 12:00; assert_equal "today", DoneTodos.completed_period(Time.zone.local(2013,1,23,9,00)) # today at 9:00 assert_equal "rest_of_week", DoneTodos.completed_period(Time.zone.local(2013,1,21)) # monday this week assert_equal "rest_of_month", DoneTodos.completed_period(Time.zone.local(2013,1,8)) # tuestday in first week of jan @@ -30,13 +30,13 @@ module Todos todos = users(:admin_user).todos # When I mark a todo complete on jan 1 - Timecop.travel(2013,1,1,0,0) do + travel_to Time.zone.local(2013,1,1,0,0) do t = users(:admin_user).todos.active.first t.complete! end # Then I should be in rest_of_week on jan 2 - Timecop.travel(2013,1,2,0,0) do + travel_to Time.zone.local(2013,1,2,0,0) do assert 0, DoneTodos.done_today(todos.reload, {}).count assert 1, DoneTodos.done_rest_of_week(todos.reload, {}).count end @@ -46,13 +46,13 @@ module Todos todos = users(:admin_user).todos # When I mark a todo complete on jan 1 - Timecop.travel(2013,1,1,0,0) do + travel_to Time.zone.local(2013,1,1,0,0) do t = users(:admin_user).todos.active.first t.complete! end # Then I should be in rest_of_month on jan 21 - Timecop.travel(2013,1,21,0,0) do + travel_to Time.zone.local(2013,1,21,0,0) do assert 0, DoneTodos.done_today(todos.reload, {}).count assert 0, DoneTodos.done_rest_of_week(todos.reload, {}).count assert 1, DoneTodos.done_rest_of_month(todos.reload, {}).count diff --git a/test/models/user_test.rb b/test/models/user_test.rb index e308f84e..7929b8a8 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -1,5 +1,4 @@ require File.expand_path(File.dirname(__FILE__) + '/../test_helper') -require 'timecop' class UserTest < ActiveSupport::TestCase fixtures :users, :preferences, :projects, :contexts, :todos, :recurring_todos @@ -351,7 +350,7 @@ class UserTest < ActiveSupport::TestCase assert_nil u.remember_token_expires_at # set token on 2013-feb-28 - Timecop.travel(Time.local(2013, 2, 28)) do + travel_to Time.local(2013, 2, 28) do u.remember_me assert_not_nil u.remember_token_expires_at @@ -359,12 +358,12 @@ class UserTest < ActiveSupport::TestCase end # token should be valid after 5 days - Timecop.travel(Time.local(2013, 3, 5)) do + travel_to Time.local(2013, 3, 5) do assert u.remember_token? end # token should not be valid after more than 2 weeks - Timecop.travel(Time.local(2013, 3, 28)) do + travel_to Time.local(2013, 3, 28) do assert !u.remember_token? end end