diff --git a/app/controllers/content_items_controller.rb b/app/controllers/content_items_controller.rb index ae1eebd5f..28092357a 100644 --- a/app/controllers/content_items_controller.rb +++ b/app/controllers/content_items_controller.rb @@ -1,7 +1,6 @@ require "slimmer/headers" class ContentItemsController < ApplicationController - include ContentsListAbTestable include GovukPersonalisation::ControllerConcern include Slimmer::Headers include Slimmer::Template @@ -16,9 +15,6 @@ class ContentItemsController < ApplicationController rescue_from PresenterBuilder::SpecialRouteReturned, with: :error_notfound rescue_from PresenterBuilder::GovernmentReturned, with: :error_notfound - helper_method :contents_list_variant - helper_method :step_by_step_page_under_test? - attr_accessor :content_item, :taxonomy_navigation content_security_policy do |p| @@ -36,10 +32,6 @@ def show elsif is_history_page? show_history_page else - if step_by_step_page_under_test? - set_contents_list_response_header - end - set_guide_draft_access_token if @content_item.is_a?(GuidePresenter) render_template end @@ -65,8 +57,6 @@ def service_sign_in_options private - helper_method :show_contents_list_ab_test? - def is_history_page? @content_item.document_type == "history" end diff --git a/app/helpers/contents_list_ab_testable.rb b/app/helpers/contents_list_ab_testable.rb deleted file mode 100644 index bf48befde..000000000 --- a/app/helpers/contents_list_ab_testable.rb +++ /dev/null @@ -1,61 +0,0 @@ -module ContentsListAbTestable - ALLOWED_VARIANTS = %w[A B Z].freeze - - AB_TEST_PAGES = [ - # Help paying for childcare - "/help-with-childcare-costs", - "/help-with-childcare-costs/free-childcare-and-education-for-3-to-4-year-olds", - "/help-with-childcare-costs/free-childcare-2-year-olds-claim-benefits", - "/help-with-childcare-costs/tax-credits", - "/help-with-childcare-costs/universal-credit", - "/help-with-childcare-costs/childcare-vouchers", - "/help-with-childcare-costs/support-while-you-study", - # What to do after someone dies - "/after-a-death", - "/after-a-death/when-a-death-is-reported-to-a-coroner", - "/after-a-death/death-abroad", - "/after-a-death/organisations-you-need-to-contact-and-tell-us-once", - "/after-a-death/report-without-tell-us-once", - "/after-a-death/arrange-the-funeral", - "/after-a-death/if-a-child-or-baby-dies", - "/after-a-death/bereavement-help-and-support", - # Become a sole trader - "/become-sole-trader", - "/become-sole-trader/choose-your-business-name", - "/become-sole-trader/register-sole-trader", - # Set up a private limited company - "/limited-company-formation", - "/limited-company-formation/choose-company-name", - "/limited-company-formation/company-address", - "/limited-company-formation/appoint-directors-and-company-secretaries", - "/limited-company-formation/shareholders", - "/limited-company-formation/memorandum-and-articles-of-association", - "/limited-company-formation/register-your-company", - "/limited-company-formation/add-corporation-tax-services-to-business-tax-account", - ].freeze - - def contents_list_test - @contents_list_test ||= GovukAbTesting::AbTest.new( - "ContentsList", - allowed_variants: ALLOWED_VARIANTS, - control_variant: "Z", - ) - end - - def contents_list_variant - contents_list_test.requested_variant(request.headers) - end - - def set_contents_list_response_header - contents_list_variant.configure_response(response) - end - - def show_contents_list_ab_test? - var_b = contents_list_variant.variant?("B") - step_by_step_page_under_test? && var_b - end - - def step_by_step_page_under_test? - AB_TEST_PAGES.include? request.path - end -end diff --git a/app/views/content_items/guide.html.erb b/app/views/content_items/guide.html.erb index d2dd373ff..4c9230a74 100644 --- a/app/views/content_items/guide.html.erb +++ b/app/views/content_items/guide.html.erb @@ -5,7 +5,7 @@ canonical_url: @content_item.canonical_url, body: @content_item.has_parts? ? @content_item.current_part_body : nil ) %> - <%= contents_list_variant.analytics_meta_tag.html_safe if step_by_step_page_under_test? %> + <%= @requested_variant.analytics_meta_tag.html_safe if @requested_variant.present? %> <% end %> @@ -19,22 +19,13 @@
- <% if show_contents_list_ab_test? %> - <%= render 'govuk_publishing_components/components/heading', { - text: @content_item.title, - heading_level: 1, - font_size: "xl", - margin_bottom: 8 - } %> - <% else %> - <%= render 'govuk_publishing_components/components/heading', { - text: @content_item.content_title, - heading_level: 1, - font_size: "xl", - margin_bottom: 8 - } %> - <% end %> - <% if show_contents_list_ab_test? || @content_item.show_guide_navigation? %> + <%= render 'govuk_publishing_components/components/heading', { + text: @content_item.content_title, + heading_level: 1, + font_size: "xl", + margin_bottom: 8 + } %> + <% if @content_item.show_guide_navigation? %> <%= render "govuk_publishing_components/components/skip_link", { text: t("guide.skip_contents"), href: "#guide-contents" @@ -47,7 +38,7 @@
<% if @content_item.has_parts? %> - <% if show_contents_list_ab_test? || @content_item.show_guide_navigation? %> + <% if @content_item.show_guide_navigation? %> <%= render 'govuk_publishing_components/components/heading', heading_level: 1, font_size: 'l', margin_bottom: 6, text: @content_item.current_part_title %> <% end %> <% @@ -64,7 +55,7 @@ <%= raw(@content_item.current_part_body) %> <% end %> - <% if show_contents_list_ab_test? || @content_item.show_guide_navigation? %> + <% if @content_item.show_guide_navigation? %> <%= render 'govuk_publishing_components/components/previous_and_next_navigation', @content_item.previous_and_next_navigation %>
diff --git a/test/controllers/content_items_controller_test.rb b/test/controllers/content_items_controller_test.rb index 7ae83455a..d7be54947 100644 --- a/test/controllers/content_items_controller_test.rb +++ b/test/controllers/content_items_controller_test.rb @@ -368,48 +368,6 @@ class ContentItemsControllerTest < ActionController::TestCase assert_equal "true", @response.headers[Slimmer::Headers::REMOVE_SEARCH_HEADER] end - test "Contents List AB test variant A" do - content_item = content_store_has_schema_example("guide", "guide-with-step-navs") - content_item["base_path"] = "/help-with-childcare-costs/support-while-you-study" - content_item["details"]["hide_chapter_navigation"] = true - - stub_content_store_has_item(content_item["base_path"], content_item) - - with_variant ContentsList: "A" do - get :show, params: { path: "help-with-childcare-costs/support-while-you-study" } - assert_response :success - assert_not response.body.include?("contents-list") - end - end - - test "Contents List AB test variant B" do - content_item = content_store_has_schema_example("guide", "guide-with-step-navs") - content_item["base_path"] = "/help-with-childcare-costs/support-while-you-study" - content_item["details"]["hide_chapter_navigation"] = true - - stub_content_store_has_item(content_item["base_path"], content_item) - - with_variant ContentsList: "B" do - get :show, params: { path: "help-with-childcare-costs/support-while-you-study" } - assert_response :success - assert response.body.include?("contents-list") - end - end - - test "Contents List AB test variant Z" do - content_item = content_store_has_schema_example("guide", "guide-with-step-navs") - content_item["base_path"] = "/help-with-childcare-costs/support-while-you-study" - content_item["details"]["hide_chapter_navigation"] = true - - stub_content_store_has_item(content_item["base_path"], content_item) - - with_variant ContentsList: "Z" do - get :show, params: { path: "help-with-childcare-costs/support-while-you-study" } - assert_response :success - assert_not response.body.include?("contents-list") - end - end - def path_for(content_item, locale = nil) base_path = content_item["base_path"].sub(/^\//, "") base_path.gsub!(/\.#{locale}$/, "") if locale