From 200b2c78ffa39c216530c6a0f902ee75a2093ddf Mon Sep 17 00:00:00 2001 From: David Singleton Date: Fri, 15 Apr 2016 10:20:53 +0100 Subject: [PATCH 1/2] Add register-to-vote promo on transaction done pages Only on completed transaction format (though we'll extend it to transaction pages in the near future). Exclude register to vote done page, as there is not a lot of point promoing something you've just done. As some done pages will have register-to-vote links in their related links we need to exclude those, and if they're the only link in a group, the group as well. Filtering the register-to-vote link out of the related_artefacts before grouping makes this much easier, but should only be done for pages where we're showing the promo. Note: register-to-vote is filtered out by content id, as the related artefacts don't have path/slug field, and the full web_url is pretty long, and can vary per environment, so use the content_id, which should be stable. Note: the changes to the tests are not super elegant, but this change is likely to be reverted wholesale once the promo is complete, this isn't a pattern we're planning to keep around. --- app/views/root/related.raw.html.erb | 29 +++++++++++++++++++++-- test/integration/related_template_test.rb | 25 +++++++++++++++---- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/app/views/root/related.raw.html.erb b/app/views/root/related.raw.html.erb index 41e76551c..6f1984160 100644 --- a/app/views/root/related.raw.html.erb +++ b/app/views/root/related.raw.html.erb @@ -1,10 +1,34 @@ <%# Whilst they are both in use, this and the test copy in slimmer should be kept in sync %> -<% if artefact and (artefact.related_artefacts.any? or (artefact.related_external_links and artefact.related_external_links.any?)) %> + +<% + promo_target_formats = ['completed_transaction', 'transaction'] + promo_excluded_regex = /register-to-vote/ + + has_promo_callout = (artefact and promo_target_formats.include?(artefact.format) and not promo_excluded_regex.match(URI.decode(artefact.slug))) +%> +<%# Whilst they are both in use, this and the test copy in slimmer should be kept in sync %> +<% if artefact and (artefact.related_artefacts.any? or (artefact.related_external_links and artefact.related_external_links.any?) or has_promo_callout) %>