Skip to content

Commit

Permalink
Update to show new Explore Super Menu Header
Browse files Browse the repository at this point in the history
For users who are in the B variant of the AB Test, they get a template from Static that has the new Explore Super-menu Navigation.
  • Loading branch information
chao-xian committed Jul 14, 2021
1 parent da3cec0 commit 945b49c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
16 changes: 16 additions & 0 deletions app/controllers/content_items_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
class ContentItemsController < ApplicationController
include GovukPersonalisation::AccountConcern
include Slimmer::Template
include AbTests::ExploreMenuAbTestable

rescue_from GdsApi::HTTPForbidden, with: :error_403
rescue_from GdsApi::HTTPNotFound, with: :error_notfound
rescue_from GdsApi::HTTPGone, with: :error_410
Expand All @@ -10,6 +13,11 @@ class ContentItemsController < ApplicationController
rescue_from PresenterBuilder::SpecialRouteReturned, with: :error_notfound
rescue_from PresenterBuilder::GovernmentReturned, with: :error_notfound

before_action :set_explore_menu_response
after_action :set_slimmer_template

helper_method :explore_menu_variant, :explore_menu_testable?

attr_accessor :content_item, :taxonomy_navigation

def show
Expand Down Expand Up @@ -47,6 +55,14 @@ def service_sign_in_options

private

def set_slimmer_template
if explore_menu_testable?
slimmer_template "core_layout_explore_header"
else
slimmer_template "core_layout"
end
end

def is_history_page?
@content_item.document_type == "history"
end
Expand Down
4 changes: 3 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
<meta name="description" content="<%= strip_tags(@content_item.description) %>" />
<% end %>

<%= explore_menu_variant.analytics_meta_tag.html_safe if explore_menu_testable? %>

<%= yield :extra_head_content %>
</head>
<body>
<% unless content_for(:simple_header) %>
<% unless content_for(:simple_header) || explore_menu_testable? %>
<%= render 'govuk_publishing_components/components/government_navigation', active: active_proposition %>
<% end %>

Expand Down
7 changes: 7 additions & 0 deletions test/controllers/content_items_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class ContentItemsControllerTest < ActionController::TestCase
include GdsApi::TestHelpers::ContentStore
include GovukAbTesting::MinitestHelpers
include AbTests::ExploreMenuAbTestable

test "routing handles paths with no format or locale" do
assert_routing(
Expand Down Expand Up @@ -366,6 +367,12 @@ class ContentItemsControllerTest < ActionController::TestCase
assert_equal response.headers["Access-Control-Allow-Origin"], "*"
end

test "request for Explore navigational super menu from slimmer" do
content_item = content_store_has_schema_example("case_study", "case_study")
get :show, params: { path: path_for(content_item) }
assert_response_not_modified_for_ab_test(AbTests::ExploreMenuAbTestable)
end

def path_for(content_item, locale = nil)
base_path = content_item["base_path"].sub(/^\//, "")
base_path.gsub!(/\.#{locale}$/, "") if locale
Expand Down

0 comments on commit 945b49c

Please sign in to comment.