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 d0eef363..3b7d617b 100644 --- a/test/controllers/preferences_controller_test.rb +++ b/test/controllers/preferences_controller_test.rb @@ -12,11 +12,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_recurrence_pattern_test.rb b/test/models/recurring_todos/daily_recurrence_pattern_test.rb index 5cf7e746..d49e7733 100644 --- a/test/models/recurring_todos/daily_recurrence_pattern_test.rb +++ b/test/models/recurring_todos/daily_recurrence_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 69e28ee1..346f50ff 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -207,7 +207,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 b0c0d9b6..fdece886 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