Override time_zone to be UTC in publishing-api #2786
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note the target branch for this PR is the dependabot govuk_app_config upgrade branch - we should merge that after this.
govuk_app_config sets the timezone to London in an initializer, on the theory that it should be London in all GOV.UK apps. However, as an API, publishing-api pretty much always wants to render times in UTC, and never in the London timezone. So the default of London doesn't feel correct here. An attempt was made at being explicit about using UTC everywhere in #2781, but it felt very fragile and overcomplicated.
It's a bit tricky to override the default set by govuk_app_config, because the code needs to run between the initializer govuk_app_config defines, and the active_support initializer which actually sets the timezone. In future we might want to make this a bit easier with a change to govuk_app_config, but it's not immediately clear how to do that, and for now this code should be a reliable way of keeping UTC in publishing-api.
Most of the other apps (including APIs) have already switched to the London timezone without issue. So it seems like publishing-api might be the only exception. There are a few apps with one or two failing tests, but those should be fixable (example - alphagov/content-data-api#2113).
https://trello.com/c/9EFyZapD