Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec test for Api::V1::DeserializationService#safe_date expects wrong results #2774

Closed
nicolasfranck opened this issue Dec 21, 2020 · 0 comments

Comments

@nicolasfranck
Copy link
Contributor

Please complete the following fields as applicable:

What version of the DMPRoadmap code are you running? (e.g. v2.2.0)

https://github.com/DMPRoadmap/roadmap/tree/v3.0.1

Expected behaviour:

This spec https://github.com/DMPRoadmap/roadmap/blob/v3.0.1/spec/services/api/v1/deserialization_service_spec.rb
should succeed, no matter the time zone it runs in.

Actual behaviour:

If you run this spec in time zone that is higher than UTC (e.g. Brussels),
then some these tests fail:

https://github.com/DMPRoadmap/roadmap/blob/v3.0.1/spec/services/api/v1/deserialization_service_spec.rb#L188

Steps to reproduce:

  • Run this from a different timezone higher than UTC

What happens in safe_date:

  • The variable expected with value 2020-11-11 is parsed by safe_date as a local time into an appropriate Time object with time zone support: 2020-11-11T00:00:00+01:00
  • That result is then converted to UTC: 2020-11-10T23:00:00Z
  • the spec expects the string to start with 2020-11-11, which fails in this timezone

What should happen:

  • compare expected to [Time object].localtime.to_s instead of to the stringified version of UTC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants