This fixes failing tests when the timezone is different than utc

There were several problems:
* Time.now returns the systems time, not the users time
* fixtures do not translate dates from timezone to utc, but stores the
  date verbatim
* calling a controller will set the timezone to the preference of the
  current_user. So it could be changed while you do not realize this. I
  fixed the failing test, but problems could be elsewhere
This commit is contained in:
Reinier Balt 2015-08-04 23:08:13 +02:00
parent 0b44fe3f08
commit e58379e81f
27 changed files with 221 additions and 214 deletions

View file

@ -16,14 +16,14 @@ class TodoCreateParamsHelperTest < ActiveSupport::TestCase
end
def test_show_from_accessor
expected_date = Time.now
expected_date = Time.zone.now
params = ActionController::Parameters.new({ 'todo' => { 'show_from' => expected_date}})
params_helper = Todos::TodoCreateParamsHelper.new(params, users(:admin_user))
assert_equal(expected_date, params_helper.show_from)
end
def test_due_accessor
expected_date = Time.now
expected_date = Time.zone.now
params = ActionController::Parameters.new({ 'todo' => { 'due' => expected_date}})
params_helper = Todos::TodoCreateParamsHelper.new(params, users(:admin_user))
assert_equal(expected_date, params_helper.due)
@ -119,5 +119,4 @@ class TodoCreateParamsHelperTest < ActiveSupport::TestCase
params_helper = Todos::TodoCreateParamsHelper.new(params, users(:admin_user))
assert_equal false, params_helper.context_specified_by_name?
end
end