1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fixed tests so that they will also run properly in other timezones.

This commit is contained in:
Willem van Bergen 2011-09-15 09:50:39 -04:00
parent bffaa888ac
commit a8aaef6762
2 changed files with 4 additions and 4 deletions

View file

@ -44,8 +44,8 @@ class MessageEncryptorTest < Test::Unit::TestCase
@encryptor.serializer = lambda { |value| ActiveSupport::JSON.encode(value) } @encryptor.serializer = lambda { |value| ActiveSupport::JSON.encode(value) }
@encryptor.deserializer = lambda { |value| ActiveSupport::JSON.decode(value) } @encryptor.deserializer = lambda { |value| ActiveSupport::JSON.decode(value) }
message = @encryptor.encrypt_and_sign({ :foo => 123, 'bar' => Time.local(2010) }) message = @encryptor.encrypt_and_sign({ :foo => 123, 'bar' => Time.utc(2010) })
assert_equal @encryptor.decrypt_and_verify(message), { "foo" => 123, "bar" => "2010-01-01T00:00:00-05:00" } assert_equal @encryptor.decrypt_and_verify(message), { "foo" => 123, "bar" => "2010-01-01T00:00:00Z" }
end end
private private

View file

@ -37,8 +37,8 @@ class MessageVerifierTest < Test::Unit::TestCase
@verifier.serializer = lambda { |value| ActiveSupport::JSON.encode(value) } @verifier.serializer = lambda { |value| ActiveSupport::JSON.encode(value) }
@verifier.deserializer = lambda { |value| ActiveSupport::JSON.decode(value) } @verifier.deserializer = lambda { |value| ActiveSupport::JSON.decode(value) }
message = @verifier.generate({ :foo => 123, 'bar' => Time.local(2010) }) message = @verifier.generate({ :foo => 123, 'bar' => Time.utc(2010) })
assert_equal @verifier.verify(message), { "foo" => 123, "bar" => "2010-01-01T00:00:00-05:00" } assert_equal @verifier.verify(message), { "foo" => 123, "bar" => "2010-01-01T00:00:00Z" }
end end
def assert_not_verified(message) def assert_not_verified(message)