diff --git a/test/functional/todos_controller_test.rb b/test/functional/todos_controller_test.rb index 864a295b..e65c67a6 100644 --- a/test/functional/todos_controller_test.rb +++ b/test/functional/todos_controller_test.rb @@ -426,6 +426,7 @@ class TodosControllerTest < ActionController::TestCase # link todo_1 and recurring_todo_1 recurring_todo_1 = RecurringTodo.find(1) + set_user_to_current_time_zone(recurring_todo_1.user) todo_1 = Todo.find_by_recurring_todo_id(1) today = Time.now.at_midnight diff --git a/test/test_helper.rb b/test/test_helper.rb index 318fe69f..3272bc17 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -82,8 +82,23 @@ class ActiveSupport::TestCase end end end - - + + def set_user_to_current_time_zone(user) + jan_offset = Time.now.beginning_of_year.utc_offset + jul_offset = Time.now.beginning_of_year.change(:month => 7).utc_offset + offset = jan_offset < jul_offset ? jan_offset : jul_offset + offset = if offset.to_s.match(/(\+|-)?(\d+):(\d+)/) + sign = $1 == '-' ? -1 : 1 + hours, minutes = $2.to_f, $3.to_f + ((hours * 3600) + (minutes.to_f * 60)) * sign + elsif offset.to_f.abs <= 13 + offset.to_f * 3600 + else + offset.to_f + end + zone = ActiveSupport::TimeZone.all.find{|t| t.utc_offset == offset} + user.prefs.update_attribute(:time_zone, zone.name) + end end class ActionController::IntegrationTest