From d7fbcb10c44978c9dfef7ef818629d8f11e573ef Mon Sep 17 00:00:00 2001 From: Matteo Giaccone Date: Tue, 30 Dec 2014 22:56:19 +0000 Subject: [PATCH] Fix #1722 --- app/controllers/preferences_controller.rb | 2 +- config/application.rb | 2 +- test/controllers/preferences_controller_test.rb | 4 ++-- test/fixtures/todos.yml | 2 ++ test/models/recurring_todos/daily_repeat_pattern_test.rb | 2 +- test/models/user_test.rb | 2 +- test/test_helper.rb | 3 ++- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/controllers/preferences_controller.rb b/app/controllers/preferences_controller.rb index a88e5fc1..bf799e55 100644 --- a/app/controllers/preferences_controller.rb +++ b/app/controllers/preferences_controller.rb @@ -28,7 +28,7 @@ class PreferencesController < ApplicationController def render_date_format format = params[:date_format] - render :text => l(Date.today, :format => format) + render :text => l(Date.current, :format => format) end private diff --git a/config/application.rb b/config/application.rb index 1620cffe..e5c7be23 100644 --- a/config/application.rb +++ b/config/application.rb @@ -22,7 +22,7 @@ module Tracksapp # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' - config.time_zone = SITE_CONFIG['time_zone'] + config.time_zone = SITE_CONFIG['time_zone'] # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] diff --git a/test/controllers/preferences_controller_test.rb b/test/controllers/preferences_controller_test.rb index f87eb1a0..6ea0a436 100644 --- a/test/controllers/preferences_controller_test.rb +++ b/test/controllers/preferences_controller_test.rb @@ -17,11 +17,11 @@ class PreferencesControllerTest < ActionController::TestCase get :render_date_format assert_response :success - assert_equal I18n.l(Date.today, :format => "%Y-%m-%d"), @response.body + assert_equal I18n.l(Date.current, :format => "%Y-%m-%d"), @response.body get(:render_date_format, {:date_format => "%A %Y"}) assert_response :success - assert_equal I18n.l(Date.today, :format => "%A %Y"), @response.body + assert_equal I18n.l(Date.current, :format => "%A %Y"), @response.body end test "index page requires login" do diff --git a/test/fixtures/todos.yml b/test/fixtures/todos.yml index ce26e327..7dc2b656 100644 --- a/test/fixtures/todos.yml +++ b/test/fixtures/todos.yml @@ -1,6 +1,8 @@ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html <% +Time.zone = SITE_CONFIG['time_zone'] + def today Time.zone.now.beginning_of_day.to_s(:db) end diff --git a/test/models/recurring_todos/daily_repeat_pattern_test.rb b/test/models/recurring_todos/daily_repeat_pattern_test.rb index 520ea346..2a903139 100644 --- a/test/models/recurring_todos/daily_repeat_pattern_test.rb +++ b/test/models/recurring_todos/daily_repeat_pattern_test.rb @@ -53,7 +53,7 @@ module RecurringTodos assert_equal_dmy @today, due_date # when the last todo was completed today, the next todo is due tomorrow - due_date =@every_day.get_due_date(@today) + due_date = @every_day.get_due_date(@today) assert_equal @tomorrow, due_date # do something every 14 days diff --git a/test/models/user_test.rb b/test/models/user_test.rb index a7122c0c..2e77a753 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -208,7 +208,7 @@ class UserTest < ActiveSupport::TestCase def test_find_and_activate_deferred_todos_that_are_ready assert_equal 1, @admin_user.deferred_todos.count @admin_user.deferred_todos[0].show_from = Time.now.utc - 5.seconds - @admin_user.deferred_todos[0].save + @admin_user.deferred_todos[0].save(:validate => false) @admin_user.deferred_todos.reload @admin_user.deferred_todos.find_and_activate_ready @admin_user.deferred_todos.reload diff --git a/test/test_helper.rb b/test/test_helper.rb index 83b1cf11..4912f6d8 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -13,7 +13,8 @@ class ActiveSupport::TestCase fixtures :all def setup - @today = Time.now.utc + Time.zone = SITE_CONFIG['time_zone'] + @today = Time.zone.now @tomorrow = @today + 1.day @in_three_days = @today + 3.days @in_four_days = @in_three_days + 1.day # need a day after start_from