diff --git a/app/assets/stylesheets/components/_blue-box-campaign.scss b/app/assets/stylesheets/components/_blue-box-campaign.scss deleted file mode 100644 index 9153a2b27..000000000 --- a/app/assets/stylesheets/components/_blue-box-campaign.scss +++ /dev/null @@ -1,43 +0,0 @@ -.app-c-native-blue-box-campaign__container { - border-top: 1px solid $border-colour; - padding-top: 20px; -} - -.app-c-native-blue-box-campaign__link { - @include bold-24; - position: relative; - display: block; - background: $govuk-blue; - width: 100%; - min-height: 280px; - color: $white; - text-decoration: none; - text-align: left; - box-sizing: border-box; - padding: 15px; -} - -.app-c-native-blue-box-campaign__title { - display: block; - color: $white; - font-weight: bold; - - &:hover { - text-decoration: underline; - } -} - -.app-c-native-blue-box-campaign__description { - @include core-19; - display: block; - font-weight: normal; - padding: 10px 10px 10px 0; - color: $white; - position: absolute; - bottom: 10px; -} - -.app-c-native-blue-box-campaign__link:focus .app-c-native-blue-box-campaign__title, -.app-c-native-blue-box-campaign__link:focus .app-c-native-blue-box-campaign__description { - color: $black; -} diff --git a/app/assets/stylesheets/components/_native-campaign.scss b/app/assets/stylesheets/components/_native-campaign.scss deleted file mode 100644 index c2590bc3d..000000000 --- a/app/assets/stylesheets/components/_native-campaign.scss +++ /dev/null @@ -1,31 +0,0 @@ -$dark-grey: #999; - -.app-c-native-campaign__container { - border-top: 1px solid $border-colour; - padding-top: 20px; -} - -.app-c-native-campaign__header { - @include core-14; - color: $dark-grey; - display: inline-block; - padding: 4px 6px 1px; - border: 1px solid $border-colour; - border-radius: 4px; -} - -.app-c-native-campaign__link { - margin-top: 15px; - display: block; - text-decoration: none; - @include bold-19; - - &:hover { - text-decoration: underline; - } -} - -.app-c-native-campaign__description { - @include core-14; - padding-top: 5px; -} diff --git a/app/controllers/concerns/contextual_comms_ab_testable.rb b/app/controllers/concerns/contextual_comms_ab_testable.rb deleted file mode 100644 index 3587386b8..000000000 --- a/app/controllers/concerns/contextual_comms_ab_testable.rb +++ /dev/null @@ -1,176 +0,0 @@ -module ContextualCommsAbTestable - GOOGLE_ANALYTICS_CUSTOM_DIMENSION = 70 - CAMPAIGN_DATA = { - get_in_go_far: { - title: "Get In Go Far", - description: "Search thousands of apprenticeships from great companies, with more added every day.", - link: "https://www.getingofar.gov.uk/", - }, - eating: { - title: "How healthy is your food?", - description: "Find out more about calories, the benefits of eating well and simple ways you can make a change.", - link: "https://www.nhs.uk/oneyou/eating", - }, - check_your_pay: { - title: "Check Your Pay", - description: "Are you being underpaid? Find out if your employer is giving you less than the legal minimum.", - link: "https://checkyourpay.campaign.gov.uk", - }, - your_pension: { - title: "Get to know your state pension", - description: "Get an online forecast to tell you how much you might get, and the earliest you can claim it.", - link: "https://www.yourpension.gov.uk/", - } - }.freeze - - def self.included(base) - base.helper_method( - :campaign_description, - :campaign_link, - :campaign_title, - :contextual_comms_test_variant, - :show_blue_box_campaign?, - :show_contextual_comms_campaign?, - :show_native_campaign?, - :whitelisted_campaign_page?, - ) - base.after_action :set_test_response_header - end - - def contextual_comms_test - @contextual_comms_test ||= GovukAbTesting::AbTest.new( - "ContextualComms", - dimension: GOOGLE_ANALYTICS_CUSTOM_DIMENSION, - allowed_variants: %w(NoCampaign BlueBoxCampaign NativeCampaign), - control_variant: "NoCampaign" - ) - end - - def contextual_comms_test_variant - @contextual_comms_test_variant ||= contextual_comms_test.requested_variant(request.headers) - end - - def set_test_response_header - contextual_comms_test_variant.configure_response(response) if whitelisted_campaign_page? - end - - def show_contextual_comms_campaign? - !contextual_comms_test_variant.variant?("NoCampaign") && whitelisted_campaign_page? - end - - def show_blue_box_campaign? - contextual_comms_test_variant.variant?("BlueBoxCampaign") - end - - def show_native_campaign? - contextual_comms_test_variant.variant?("NativeCampaign") - end - - def whitelisted_campaign_page? - campaign_name.present? - end - - def campaign_name - @campaign_name ||= - if EATING_PAGES.include?(content_item_path) - :eating - elsif CHECK_YOUR_PAY_PAGES.include?(content_item_path) - :check_your_pay - elsif YOUR_PENSION_PAGES.include?(content_item_path) - :your_pension - end - end - - def campaign_link - CAMPAIGN_DATA[campaign_name][:link] + - "?utm_source=#{content_item_path}" + - "&utm_content=#{contextual_comms_test_variant.variant_name}" + - "&utm_campaign=ukgov-promo&utm_medium=referral" - end - - def campaign_title - CAMPAIGN_DATA[campaign_name][:title] - end - - def campaign_description - CAMPAIGN_DATA[campaign_name][:description] - end - - GET_IN_GO_FAR_PAGES = %w( - /career-skills-and-training - /mature-student-university-funding - /higher-education-courses-find-and-apply - /what-different-qualification-levels-mean - /what-different-qualification-levels-mean/list-of-qualification-levels - /what-different-qualification-levels-mean/compare-different-qualification-levels - /further-education-courses - /improve-english-maths-it-skills - /further-education-courses - /further-education-courses/financial-help - /further-education-courses/find-a-course - /looking-for-work-if-disabled - /exoffenders-and-employment - ).freeze - - EATING_PAGES = %w( - /free-school-transport - /healthy-start - /healthy-start/eligibility - /healthy-start/how-to-claim - /healthy-start/what-youll-get - /help-with-childcare-costs - /help-with-childcare-costs/childcare-vouchers - /help-with-childcare-costs/free-childcare-2-year-olds - /help-with-childcare-costs/free-childcare-2-year-olds-benefits - /help-with-childcare-costs/free-childcare-and-education-for-2-to-4-year-olds - /help-with-childcare-costs/support-while-you-study - /help-with-childcare-costs/tax-credits - /help-with-childcare-costs/tax-free-childcare - /help-with-childcare-costs/universal-credit - /school-uniform - ).freeze - - CHECK_YOUR_PAY_PAGES = %w( - /pay-and-work-rights - /payslips - /report-cash-in-hand-pay - /student-jobs-paying-tax - /tips-at-work - /tips-at-work/tips-and-tax - /understanding-your-pay/deductions-from-your-pay - /understanding-your-pay/pay-calculations-if-you-work-shifts-or-get-bonuses - /understanding-your-pay/working-out-your-pay - /employment-contracts-and-conditions - /employment-contracts-and-conditions/collective-agreements - /employment-contracts-and-conditions/contract-terms - /employment-contracts-and-conditions/written-statement-of-employment-particulars - /employment-status - /employment-status/employee - /employment-status/worker - /flexible-working - /flexible-working/types-of-flexible-working - /maximum-weekly-working-hours - /maximum-weekly-working-hours/calculating-your-working-hours - /maximum-weekly-working-hours/weekly-maximum-working-hours-and-opting-out - /night-working-hours - /overtime-your-rights - /rest-breaks-work - /rest-breaks-work/compensatory-rest - /rest-breaks-work/exceptions - /rest-breaks-work/taking-breaks - /rest-breaks-work/young-workers - ).freeze - - YOUR_PENSION_PAGES = %w( - /armed-forces-pension-calculator - /personal-pensions-your-rights - /transferring-your-pension - /pension-types - /workplace-pensions - /employers-workplace-pensions-rules - /carers-credit - /national-insurance-credits - /voluntary-national-insurance-contributions - /plan-retirement-income - ).freeze -end diff --git a/app/controllers/content_items_controller.rb b/app/controllers/content_items_controller.rb index d0f97ff65..a27a37f02 100644 --- a/app/controllers/content_items_controller.rb +++ b/app/controllers/content_items_controller.rb @@ -1,5 +1,4 @@ class ContentItemsController < ApplicationController - include ContextualCommsAbTestable rescue_from GdsApi::HTTPForbidden, with: :error_403 rescue_from GdsApi::HTTPNotFound, with: :error_notfound diff --git a/app/views/components/_blue-box-campaign.html.erb b/app/views/components/_blue-box-campaign.html.erb deleted file mode 100644 index e367df548..000000000 --- a/app/views/components/_blue-box-campaign.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -
- -

<%= title %>

- <%= description %> -
-
diff --git a/app/views/components/_native-campaign.html.erb b/app/views/components/_native-campaign.html.erb deleted file mode 100644 index b0ab1c669..000000000 --- a/app/views/components/_native-campaign.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -
- Campaign - <%= title %> -

<%= description %>

-
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 9ae1711ac..362150682 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -44,7 +44,6 @@ <% end %> - <%= contextual_comms_test_variant.analytics_meta_tag.html_safe if whitelisted_campaign_page? %> <%= yield :extra_head_content %> diff --git a/app/views/shared/_sidebar_navigation.html.erb b/app/views/shared/_sidebar_navigation.html.erb index 5dabffc12..887450c4e 100644 --- a/app/views/shared/_sidebar_navigation.html.erb +++ b/app/views/shared/_sidebar_navigation.html.erb @@ -1,12 +1,3 @@
<%= render 'govuk_publishing_components/components/contextual_sidebar', content_item: @content_item.content_item.parsed_content %> - - <% if show_contextual_comms_campaign? %> - <% if show_blue_box_campaign? %> - <%= render 'components/blue-box-campaign', title: campaign_title, description: campaign_description, href: campaign_link %> - <% end %> - <% if show_native_campaign? %> - <%= render 'components/native-campaign', title: campaign_title, description: campaign_description, href: campaign_link %> - <% end %> - <% end %>
diff --git a/test/components/blue_box_campaign_test.rb b/test/components/blue_box_campaign_test.rb deleted file mode 100644 index afbba36fb..000000000 --- a/test/components/blue_box_campaign_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'component_test_helper' - -class BlueBoxCampaignTest < ComponentTestCase - def component_name - "blue-box-campaign" - end - - test "fails to render a blue box campaign link when no parameters given" do - assert_raise do - render_component({}) - end - end - - test "renders a blue box campaign link when required params are given" do - render_component(title: "Campaign about things", description: "Look at this campaign about things", href: "https://www.gov.uk/things") - assert_select "h2", "Campaign about things" - assert_select "a", href: /https:\/\/www.gov.uk\/things/ - assert_select "span", "Look at this campaign about things" - end -end diff --git a/test/components/native_campaign_test.rb b/test/components/native_campaign_test.rb deleted file mode 100644 index 0206758e5..000000000 --- a/test/components/native_campaign_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'component_test_helper' - -class NativeCampaignTest < ComponentTestCase - def component_name - "native-campaign" - end - - test "fails to render a native campaign link when no parameters given" do - assert_raise do - render_component({}) - end - end - - test "renders a native campaign link when required params are given" do - render_component(title: "Campaign about things", description: "Look at this campaign about things", href: "https://www.gov.uk/things") - assert_select "a", "Campaign about things" - assert_select "a", href: /https:\/\/www.gov.uk\/things/ - assert_select "p", "Look at this campaign about things" - end -end diff --git a/test/controllers/contextual_comms_ab_test_controller_test.rb b/test/controllers/contextual_comms_ab_test_controller_test.rb deleted file mode 100644 index 961596538..000000000 --- a/test/controllers/contextual_comms_ab_test_controller_test.rb +++ /dev/null @@ -1,110 +0,0 @@ -require "test_helper" - -class ContentItemsControllerTest < ActionController::TestCase - include GdsApi::TestHelpers::ContentStore - include GovukAbTesting::MinitestHelpers - - # govuk_base_path is an example page that is eligible to show a campaign. - CAMPAIGNS = { - # get_in_go_far: { - # govuk_base_path: "/career-skills-and-training", - # title: "Get In Go Far", - # description: "Search thousands of apprenticeships from great companies, with more added every day.", - # href: "https://www.getingofar.gov.uk/", - # }, - eating: { - govuk_base_path: "/free-school-transport", - title: "How healthy is your food?", - description: "Find out more about calories, the benefits of eating well and simple ways you can make a change.", - href: "https://www.nhs.uk/oneyou/eating", - }, - check_your_pay: { - govuk_base_path: "/pay-and-work-rights", - title: "Check Your Pay", - description: "Are you being underpaid? Find out if your employer is giving you less than the legal minimum.", - href: "https://checkyourpay.campaign.gov.uk", - }, - your_pension: { - govuk_base_path: "/armed-forces-pension-calculator", - title: "Get to know your state pension", - description: "Get an online forecast to tell you how much you might get, and the earliest you can claim it.", - href: "https://www.yourpension.gov.uk/", - } - }.freeze - - test "ContextualComms shows no campaigns for variant 'NoCampaign'" do - CAMPAIGNS.each_value do |value| - content_item = set_content_item(value[:govuk_base_path]) - content_store_has_item(value[:govuk_base_path], content_item) - - with_variant ContextualComms: "NoCampaign" do - get :show, params: { path: path_for(content_item) } - assert_response 200 - - refute_match("native-campaign", response.body) - refute_match("blue-box-campaign", response.body) - end - end - end - - test "ContextualComms shows a blue box campaign for variant 'BlueBoxCampaign'" do - CAMPAIGNS.each do |key, value| - # as the campaign_name method is memoized, we need to ensure the correct campaign name is returned for each test - @controller.stubs(:campaign_name).returns(key) - content_item = set_content_item(value[:govuk_base_path]) - content_store_has_item(value[:govuk_base_path], content_item) - - with_variant ContextualComms: "BlueBoxCampaign" do - get :show, params: { path: path_for(content_item) } - assert_response 200 - - assert_match("blue-box-campaign", response.body) - assert_match(value[:title], response.body) - assert_match(value[:description], response.body) - assert_select("a:match('href', ?)", value[:href]) - end - end - end - - test "ContextualComms shows a native campaign for variant 'NativeCampaign'" do - CAMPAIGNS.each do |key, value| - # as the campaign_name method is memoized, we need to ensure the correct campaign name is returned for each test - @controller.stubs(:campaign_name).returns(key) - content_item = set_content_item(value[:govuk_base_path]) - content_store_has_item(value[:govuk_base_path], content_item) - - with_variant ContextualComms: "NativeCampaign" do - get :show, params: { path: path_for(content_item) } - assert_response 200 - - assert_match("native-campaign", response.body) - assert_match(value[:title], response.body) - assert_match(value[:description], response.body) - assert_select("a:match('href', ?)", value[:href]) - end - end - end - - test "No campaign is shown on pages that haven't been whitelisted" do - content_item = set_content_item("/an-answer") - content_store_has_item(content_item["base_path"], content_item) - - get :show, params: { path: path_for(content_item) } - assert_response 200 - - refute_match("native-campaign", response.body) - refute_match("blue-box-campaign", response.body) - end - - def set_content_item(base_path) - content_item = content_store_has_schema_example("answer", "answer") - content_item["base_path"] = base_path - content_item - end - - def path_for(content_item, locale = nil) - base_path = content_item['base_path'].sub(/^\//, '') - base_path.gsub!(/\.#{locale}$/, '') if locale - base_path - end -end