Skip to content

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

@nicolasfranck

Description

@nicolasfranck

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions