Skip to content

Commit

Permalink
Fix incorrect dates in 'Get involved' page
Browse files Browse the repository at this point in the history
  • Loading branch information
unoduetre committed Feb 12, 2025
1 parent 44f0433 commit c97f884
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 27 deletions.
4 changes: 2 additions & 2 deletions app/models/get_involved.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def next_closing_consultation
def recently_opened_consultations
query = {
filter_content_store_document_type: "open_consultation",
fields: "end_date,title,link,organisations",
fields: "public_timestamp,end_date,title,link,organisations",
order: "-start_date",
count: 3,
}
Expand All @@ -47,7 +47,7 @@ def recent_consultation_outcomes
query = {
filter_content_store_document_type: "consultation_outcome",
filter_end_date: "to: #{Time.zone.now.to_date}",
fields: "end_date,title,link,organisations",
fields: "public_timestamp,end_date,title,link,organisations",
order: "-end_date",
count: 3,
}
Expand Down
23 changes: 14 additions & 9 deletions app/presenters/get_involved_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,25 @@ def filtered_links(array, close_status)
link: {
text: item["title"],
path: item["link"],
description: "#{close_status} #{item['end_date'].to_date.strftime('%d %B %Y')}",
},
metadata: {
public_updated_at: Time.zone.parse(org_time(item)),
document_type: org_acronym(item),
description: closing_date_text(item, close_status),
},
subtext: last_updated_date_text(item),
}
end
end

def org_time(item)
item["organisations"].map { |org|
org["public_timestamp"]
}.join(", ")
def date_format
"%e %B %Y"
end

def closing_date_text(item, close_status)
"#{close_status}: #{item['end_date'].to_date.strftime(date_format)}"
end

def last_updated_date_text(item)
"#{I18n.t('formats.get_involved.last_updated')}: "\
"#{item['public_timestamp'].to_date.strftime(date_format)} "\
"(#{org_acronym(item)})"
end

def org_acronym(item)
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ en:
start_a_petition: Start a petition
take_part: Take part
take_part_suggestions: Many people are already volunteering, donating and contributing, both in the UK and abroad. If you'd like to join them, but dont know where to start, here's a list of suggestions
last_updated: Last updated
your_views: You can give your views on new or changing government policies by responding to consultations. Government departments take these responses into consideration before making decisions.
licence:
change: Change
Expand Down
4 changes: 2 additions & 2 deletions spec/models/get_involved_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def stub_search_query(query:, response:)
def consultation_result
{
"title" => "Consulting on time zones",
"public_timestamp" => "2024-10-14T00:00:00.000+01:00",
"public_timestamp" => "2024-10-11T00:00:00.000+01:00",
"end_date" => "2024-10-14T00:00:00.000+01:00",
"link" => "/consultation/link",
"organisations" => [{
Expand All @@ -68,7 +68,7 @@ def consultation_result
def next_closing_consultation
{
"title" => "Incorporating international rules",
"public_timestamp" => "2023-11-14T00:00:00.000+01:00",
"public_timestamp" => "2023-11-11T00:00:00.000+01:00",
"end_date" => "2024-11-14T00:00:00.000+01:00",
"link" => "/consultation/link",
"organisations" => [{
Expand Down
20 changes: 8 additions & 12 deletions spec/presenter/get_involved_spec.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
RSpec.describe GetInvolved do
let(:consultation_closing_november) do
{
"public_timestamp" => "2024-09-20T10:51:08.000+00:00",
"end_date" => "2024-11-28T23:59:00.000+00:00",
"title" => "Consultation on the International Council for Harmonisation (ICH) M14",
"link" => "/government/consultations/consultation-on-the-international-council-for-harmonisation-ich-m14",
"_id" => "/government/consultations/consultation-on-the-international-council-for-harmonisation-ich-m14",
"document_type" => "edition",
"organisations" => [{ "acronym" => "DfT", "title" => "Department for Transport", "public_timestamp": "2024-09-31T10:51:08.000+00:00" }],
"organisations" => [{ "acronym" => "DfT", "title" => "Department for Transport" }],
}
end

let(:consultation_closing_december) do
{
"public_timestamp" => "2024-10-20T10:51:08.000+00:00",
"end_date" => "2024-12-28T23:59:00.000+00:00",
"title" => "Consultation on the International Council",
"link" => "/government/consultations/consultation-on-the-international-council",
"_id" => "/government/consultations/consultation-on-the-international-council",
"document_type" => "edition",
"organisations" => [{ "acronym" => "Natural England", "title" => "Natural England", "public_timestamp": "2024-10-31T10:51:08.000+00:00" }],
"organisations" => [{ "acronym" => "Natural England", "title" => "Natural England" }],
}
end

Expand All @@ -33,25 +35,19 @@
expected_output = [
{
link: {
description: "Closes 28 November 2024",
description: "Closes: 28 November 2024",
path: consultation_closing_november["link"],
text: consultation_closing_november["title"],
},
metadata: {
document_type: consultation_closing_november["organisations"].first["acronym"],
public_updated_at: consultation_closing_november["organisations"].first["public_timestamp"],
},
subtext: "Last updated: 20 September 2024 (DfT)",
},
{
link: {
description: "Closes 28 December 2024",
description: "Closes: 28 December 2024",
path: consultation_closing_december["link"],
text: consultation_closing_december["title"],
},
metadata: {
document_type: consultation_closing_december["organisations"].first["acronym"],
public_updated_at: consultation_closing_december["organisations"].first["public_timestamp"],
},
subtext: "Last updated: 20 October 2024 (Natural England)",
},
]

Expand Down
12 changes: 10 additions & 2 deletions spec/system/get_involved_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
it "does not display a single page notification button" do
expect(page).not_to have_css(".gem-c-single-page-notification-button")
end

it "shows opening date" do
expect(page).to have_text("Last updated: 2 January 2022")
end

it "shows closing date" do
expect(page).to have_text("Closed: 8 February 2023")
end
end
end

Expand All @@ -47,8 +55,8 @@ def stub_search_query(query:, response:)
def consultation_result
{
"title" => "Consulting on time zones",
"public_timestamp" => "2022-02-14T00:00:00.000+01:00",
"end_date" => "2022-02-14T00:00:00.000+01:00",
"public_timestamp" => "2022-01-02T00:00:00.000+00:00",
"end_date" => "2023-02-08T00:00:00.000+00:00",
"link" => "/consultation/link",
"organisations" => [{
"slug" => "ministry-of-justice",
Expand Down

0 comments on commit c97f884

Please sign in to comment.