From 7421ab33b4563747e645fce75facf249304b34b4 Mon Sep 17 00:00:00 2001 From: David Singleton Date: Fri, 29 Jan 2016 11:43:48 +0000 Subject: [PATCH] Support Statistics announcements with changed date This applies when a 'confirmed' announcement has it's release date edited, which should not normally happen. When it does it must be disclosed, and the reason explained. In WH this disclosure is done as a separate headed section, with a second 'metadata'-style block to format the date and reason. Long term this may not be the right pattern for the page, and may be consolidated into the main metadata block, or otherwise be made more consistent with other document formats. To get the feature migrated in the short term i've included a second call to the metadata component, which causes some complexity in the integration test, where there is now two metadata components when asserting. In order to avoid the conflict, i've scoped the metadata asserts for the `release_date_changed` example only, as the others don't have multiple metadata blocks. This does add a slightly spurious class to distinguish the first/ main metadata block, but it feels better than adding a lot of complexity to the tests or test helpers. If this is a pattern we encounter in more formats in the future, then we should look at adding support to the test helpers for cases like this. --- .../views/_statistics_announcement.scss | 7 +++++++ .../statistics_announcement_presenter.rb | 12 ++++++++++++ .../statistics_announcement.html.erb | 16 +++++++++++++++- .../integration/statistics_announcement_test.rb | 17 +++++++++++++++++ .../statistics_announcement_presenter_test.rb | 13 +++++++++++++ 5 files changed, 64 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/views/_statistics_announcement.scss b/app/assets/stylesheets/views/_statistics_announcement.scss index bd736325b..4d781e616 100644 --- a/app/assets/stylesheets/views/_statistics_announcement.scss +++ b/app/assets/stylesheets/views/_statistics_announcement.scss @@ -9,4 +9,11 @@ .cancellation-notice { @include notice; } + + .release-date-change-notice { + h2 { + font-weight: bold; + margin-bottom: $gutter-half; + } + } } diff --git a/app/presenters/statistics_announcement_presenter.rb b/app/presenters/statistics_announcement_presenter.rb index 23ce8e256..3f5906bfb 100644 --- a/app/presenters/statistics_announcement_presenter.rb +++ b/app/presenters/statistics_announcement_presenter.rb @@ -22,6 +22,14 @@ def release_date_and_status release_date end + def previous_release_date + content_item["details"]["previous_display_date"] + end + + def release_date_changed? + content_item["details"].include?("previous_display_date") + end + def other_metadata if cancelled? { @@ -50,6 +58,10 @@ def cancellation_reason content_item["details"]["cancellation_reason"] end + def release_date_change_reason + content_item["details"]["latest_change_note"] + end + private def state diff --git a/app/views/content_items/statistics_announcement.html.erb b/app/views/content_items/statistics_announcement.html.erb index 7315c5eb8..b00fb13b1 100644 --- a/app/views/content_items/statistics_announcement.html.erb +++ b/app/views/content_items/statistics_announcement.html.erb @@ -18,7 +18,7 @@ <% end %> -
+