-
Notifications
You must be signed in to change notification settings - Fork 20
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
Prevent government_frontend test failure if meta tag key doesn't exist #3741
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,13 +92,12 @@ def add_political_tags(meta_tags) | |
def add_ga4_political_tags(meta_tags) | ||
government = content_item.dig(:links, :government, 0) | ||
|
||
# political: true/false is in a different place to current: true/false, which is why we have 'details' and 'government[:details]' | ||
# political: true/false is in a different place to current: true/false, which is why we have 'details' and 'government.dig(:details)' | ||
if government && details[:political] | ||
meta_tags["govuk:ga4-political-status"] = government[:details][:current] ? "political" : "historic" | ||
|
||
government_title = government[:title] | ||
if government_title && !government[:details][:current] | ||
meta_tags["govuk:ga4-publishing-government"] = government_title | ||
current_government = government.dig(:details, :current) | ||
unless current_government | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm struggling to get my head round this a bit so bear with me. This seems like quite a significant change? It used to always set the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andysellick The PAs wanted this meta tag to show on "This was published by X government" pages, and that only appears if the page was not created during the current government. If the page was written during the current government you get the "political" value, but if it was published by a previous government, it gives "historic". I had a test which was meant to check the meta tag doesn't render for the current government previously, but it was passing due to the false positive. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, sorry, just a bit confused. I can see that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andysellick No worries - It no longer gets set to Political would get set if
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah okay that's clarified things. Thanks. |
||
meta_tags["govuk:ga4-political-status"] = "historic" | ||
meta_tags["govuk:ga4-publishing-government"] = government[:title] if government[:title] | ||
end | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment still relevant? I'm not sure what it means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andysellick Populating the meta tag relies on two values existing:
details[:political]: (true/false)
government[:details][:current]: (true/false)
And the comment was trying to explain why the code is referring to two different
details
objects.