diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index 6c2d683df..f9643040a 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -17,7 +17,6 @@
@import 'helpers/add-title-margin';
@import "helpers/content-bottom-margin";
@import "helpers/publisher-metadata-with-logo";
-@import "helpers/taxonomy-navigation";
// Components from this application
@import 'components/*';
diff --git a/app/assets/stylesheets/helpers/_taxonomy-navigation.scss b/app/assets/stylesheets/helpers/_taxonomy-navigation.scss
deleted file mode 100644
index c91fcbd45..000000000
--- a/app/assets/stylesheets/helpers/_taxonomy-navigation.scss
+++ /dev/null
@@ -1,53 +0,0 @@
-// govuk_frontend_toolkit imports
-@import 'css3';
-
-.taxonomy-navigation {
- border-top: 2px solid $govuk-blue;
-}
-
-.taxonomy-navigation__banner {
- @include core-19;
-
- padding: $gutter-half $gutter-half $gutter-one-third;
- background: $grey-4;
- border: 1px solid $border-colour;
-}
-
-.taxonomy-navigation__row {
- display: flex;
- flex-wrap: wrap;
- padding-top: $gutter-one-third;
-
- @include media(tablet) {
- margin-right: -25px;
- }
-}
-
-.taxonomy-navigation__column {
- @include box-sizing(border-box);
- width: 100%;
- font-size: 16px;
- padding: ($gutter-one-third / 2) $gutter-one-third ($gutter-half + $gutter-one-third) 0;
-
- @include media(tablet) {
- width: 50%;
- padding: ($gutter-one-third / 2) ($gutter-half + $gutter-one-third) ($gutter-half + $gutter-one-third) 0;
- }
-
- @include media(desktop) {
- width: (1 / 3) * 100%;
- padding: ($gutter-one-third / 2) ($gutter-half + $gutter-one-third) ($gutter-half + $gutter-one-third) 0;
- }
-}
-
-.taxonomy-navigation__list-item {
- margin: $gutter-one-third 0 ($gutter-one-third / 2) 0;
- padding-bottom: $gutter-one-third / 2;
- list-style: none;
-}
-
-.taxonomy-navigation__section {
- padding: $gutter-one-third 0 $gutter-two-thirds 0;
- margin-top: $gutter-half;
- border-top: 1px solid $black;
-}
diff --git a/app/controllers/concerns/content_pages_nav_ab_testable.rb b/app/controllers/concerns/content_pages_nav_ab_testable.rb
deleted file mode 100644
index bbc38d9a6..000000000
--- a/app/controllers/concerns/content_pages_nav_ab_testable.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-module ContentPagesNavAbTestable
- CUSTOM_DIMENSION = 65
-
- def self.included(base)
- base.helper_method(
- :content_pages_nav_test_variant,
- :show_new_navigation?,
- :page_in_scope?,
- :should_show_sidebar?
- )
- base.after_action :set_test_response_header
- end
-
- def content_pages_nav_test
- @content_pages_nav_test ||= GovukAbTesting::AbTest.new(
- "ContentPagesNav",
- dimension: CUSTOM_DIMENSION,
- allowed_variants: %w(A B),
- control_variant: "A"
- )
- end
-
- def content_pages_nav_test_variant
- @content_pages_nav_test_variant ||= content_pages_nav_test.requested_variant(request.headers)
- end
-
- def set_test_response_header
- content_pages_nav_test_variant.configure_response(response) if page_in_scope?
- end
-
- def show_new_navigation?
- content_pages_nav_test_variant.variant?("B") && page_in_scope?
- end
-
- def page_in_scope?
- # Pages are in scope if:
- # - They are not an out-of-scope format, e.g: html publications
- # - They are tagged to the taxonomy
- if @content_item
- not_an_html_publication? && has_a_live_taxon?
- end
- end
-
- def not_an_html_publication?
- !@content_item.document_type.eql?("html_publication")
- end
-
- def has_a_live_taxon?
- @content_item.taxons.present? &&
- @content_item.taxons.detect { |taxon| taxon["phase"] == "live" }
- end
-
- def should_show_sidebar?
- content_pages_nav_test_variant.variant?("A") ||
- @content_item.step_by_steps.present? ||
- @content_item.content_item.parsed_content['publishing_app'] != "whitehall"
- end
-end
diff --git a/app/controllers/content_items_controller.rb b/app/controllers/content_items_controller.rb
index 916088815..9ccad31f1 100644
--- a/app/controllers/content_items_controller.rb
+++ b/app/controllers/content_items_controller.rb
@@ -1,5 +1,4 @@
class ContentItemsController < ApplicationController
- include ContentPagesNavAbTestable
rescue_from GdsApi::HTTPForbidden, with: :error_403
rescue_from GdsApi::HTTPNotFound, with: :error_notfound
@@ -15,8 +14,6 @@ class ContentItemsController < ApplicationController
def show
load_content_item
- load_taxonomy_navigation if show_new_navigation?
-
set_expiry
set_access_control_allow_origin_header if request.format.atom?
set_guide_draft_access_token if @content_item.is_a?(GuidePresenter)
@@ -61,54 +58,6 @@ def set_guide_draft_access_token
def load_content_item
content_item = Services.content_store.content_item(content_item_path)
@content_item = PresenterBuilder.new(content_item, content_item_path).presenter
- @content_item.include_collections_in_other_publisher_metadata = show_new_navigation?
- end
-
- def load_taxonomy_navigation
- if @content_item.taxons.present?
- current_base_path = @content_item.base_path
- taxons = @content_item.taxons.select { |taxon| taxon["phase"] == "live" }
- taxon_ids = taxons.map { |taxon| taxon["content_id"] }
-
- @taxonomy_navigation = {}
- @content_item.links_out_supergroups.each do |supergroup|
- supergroup_taxon_links = "Supergroups::#{supergroup.camelcase}".constantize.new(current_base_path, taxon_ids, filter_content_purpose_subgroup: @content_item.links_out_subgroups(supergroup))
- @taxonomy_navigation[supergroup.to_sym] = supergroup_taxon_links.tagged_content
- end
-
- @tagged_taxons = taxons.map do |taxon|
- {
- taxon_id: taxon["content_id"],
- taxon_name: taxon["title"],
- taxon_link: taxon["base_path"],
- }
- end
-
- @related_collections = @content_item
- .content_item
- .dig('links', 'document_collections')
- .yield_self { |document_collections| document_collections || [] }
- .select { |document_collection| document_collection['document_type'] == 'document_collection' }
- .map { |document_collection| document_collection.values_at('base_path', 'title') }
-
- # Fetch link attributes of parent step by steps required to render the top navigation banner
- step_by_step_links = @content_item
- .content_item
- .dig('links', 'part_of_step_navs')
- .yield_self { |part_of_step_navs| part_of_step_navs || [] }
- .sort_by { |step_by_step_nav| step_by_step_nav['title'] }
- .map { |step_by_step_nav| step_by_step_nav.values_at('title', 'base_path') }
- @banner_items = format_banner_links(step_by_step_links, "Step by Step")
-
- # Append link attributes of parent taxons to our collections of items for the top navigation banner if the
- # content item is tagged to more than one taxon. If there is only one taxon a breadcrumb will be used instead.
- if taxons.many?
- taxon_links = taxons
- .sort_by { |taxon| taxon[:taxon_name] }
- .map { |taxon| taxon.values_at('title', 'base_path') }
- @banner_items += format_banner_links(taxon_links, "Taxon")
- end
- end
end
def format_banner_links(links, type)
diff --git a/app/helpers/phase_label_helper.rb b/app/helpers/phase_label_helper.rb
index cc3b1797d..1d7da5d67 100644
--- a/app/helpers/phase_label_helper.rb
+++ b/app/helpers/phase_label_helper.rb
@@ -1,17 +1,6 @@
module PhaseLabelHelper
def render_phase_label(presented_object, message)
- if show_new_navigation?
- beta_message = <<~BETA_MESSAGE.html_safe
- This is a test version of the layout of this page.
- Take the survey to help us improve it
- BETA_MESSAGE
-
- render 'govuk_publishing_components/components/phase_banner', phase: 'beta', message: beta_message
-
- elsif presented_object.respond_to?(:phase) && %w(alpha beta).include?(presented_object.phase)
+ if presented_object.respond_to?(:phase) && %w(alpha beta).include?(presented_object.phase)
locals = {}
locals[:message] = message if message.present?
diff --git a/app/lib/services.rb b/app/lib/services.rb
index 3f7855c6a..bbec4f35a 100644
--- a/app/lib/services.rb
+++ b/app/lib/services.rb
@@ -11,9 +11,4 @@ def self.content_store
disable_cache: true,
)
end
-
- def self.rummager
- @rummager ||= GdsApi::Rummager.new(Plek.new.find("rummager"),
- timeout: 2)
- end
end
diff --git a/app/presenters/content_item/links_out.rb b/app/presenters/content_item/links_out.rb
deleted file mode 100644
index 25f38942d..000000000
--- a/app/presenters/content_item/links_out.rb
+++ /dev/null
@@ -1,109 +0,0 @@
-module ContentItem
- module LinksOut
- def links_out_supergroups
- @links_out_supergroups ||= fetch_links_out_supergroups
- end
-
- def links_out_subgroups(supergroup)
- fetch_links_out_subgroups(supergroup)
- end
-
- private
-
- def fetch_links_out_supergroups
- links_out.map { |link| link["supergroup"] }.uniq
- end
-
- def fetch_links_out_subgroups(supergroup)
- subgroups = []
- links_out.each do |link|
- if link["type"] == "content_purpose_subgroup" && link["supergroup"] == supergroup
- subgroups << link["title"]
- end
- end
- subgroups.uniq
- end
-
- def links_out
- @links_out ||= fetch_links_out
- end
-
- def fetch_links_out
- document_type_link_rule = DocumentTypeLinkRule.new(content_item)
- return document_type_link_rule.links if document_type_link_rule.any?
- subgroup_link_rule = SubgroupLinkRule.new(content_item)
- return subgroup_link_rule.links if subgroup_link_rule.any?
- SupergroupLinkRule.new(content_item).links
- end
-
- class LinkRule
- def initialize(content_item)
- @content_item = content_item
- @rules = load_rules
- @links = fetch_links
- end
-
- def any?
- !@links.nil?
- end
-
- def links
- @links || []
- end
-
- private
-
- def fetch_links
- if @content_item.dig(rule_level) &&
- @rules[rule_level] &&
- @rules[rule_level].dig(@content_item[rule_level])
- @rules[rule_level][@content_item[rule_level]]
- end
- end
-
- def load_rules
- Rails.configuration.taxonomy_navigation_links_out
- end
-
- def rule_level
- NotImplementedError
- end
- end
-
- class DocumentTypeLinkRule < LinkRule
- def initialize(content_item)
- super
- end
-
- private
-
- def rule_level
- 'document_type'
- end
- end
-
- class SubgroupLinkRule < LinkRule
- def initialize(content_item)
- super
- end
-
- private
-
- def rule_level
- 'content_purpose_subgroup'
- end
- end
-
- class SupergroupLinkRule < LinkRule
- def initialize(content_item)
- super
- end
-
- private
-
- def rule_level
- 'content_purpose_supergroup'
- end
- end
- end
-end
diff --git a/app/presenters/content_item/metadata.rb b/app/presenters/content_item/metadata.rb
index 6daa7d2e9..a9f4a706a 100644
--- a/app/presenters/content_item/metadata.rb
+++ b/app/presenters/content_item/metadata.rb
@@ -20,18 +20,14 @@ def important_metadata
end
def publisher_metadata
- {}.tap do |publisher_metadata|
- publisher_metadata[:published] = published
- publisher_metadata[:last_updated] = updated
- publisher_metadata[:link_to_history] = !!updated
- publisher_metadata[:other] = {
- from: from,
+ {
+ published: published,
+ last_updated: updated,
+ link_to_history: !!updated,
+ other: {
+ from: from
}
-
- if include_collections_in_other_publisher_metadata
- publisher_metadata[:other][:collections] = links('document_collections')
- end
- end
+ }
end
end
end
diff --git a/app/presenters/content_item_presenter.rb b/app/presenters/content_item_presenter.rb
index f2bde825c..e2c0e1277 100644
--- a/app/presenters/content_item_presenter.rb
+++ b/app/presenters/content_item_presenter.rb
@@ -1,6 +1,5 @@
class ContentItemPresenter
include ContentItem::Withdrawable
- include ContentItem::LinksOut
attr_reader :content_item,
:requested_content_item_path,
diff --git a/app/presenters/supergroups/guidance_and_regulation.rb b/app/presenters/supergroups/guidance_and_regulation.rb
deleted file mode 100644
index 2df25efe2..000000000
--- a/app/presenters/supergroups/guidance_and_regulation.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-module Supergroups
- class GuidanceAndRegulation < Supergroup
- def initialize(current_path, taxon_ids, filters)
- super(current_path, taxon_ids, filters, MostPopularContent)
- end
-
- def tagged_content
- format_document_data(@content, include_timestamp: false)
- end
- end
-end
diff --git a/app/presenters/supergroups/news_and_communications.rb b/app/presenters/supergroups/news_and_communications.rb
deleted file mode 100644
index cb517e1ae..000000000
--- a/app/presenters/supergroups/news_and_communications.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-module Supergroups
- class NewsAndCommunications < Supergroup
- attr_reader :content
-
- PLACEHOLDER_IMAGE = "#{Plek.current.asset_root}/government/assets/placeholder.jpg".freeze
-
- def initialize(current_path, taxon_ids, filters)
- super(current_path, taxon_ids, filters, MostRecentContent)
- end
-
- def tagged_content
- format_document_data(@content)
- end
-
- private
-
- def format_document_data(documents)
- # Start with_index at 1 to help align analytics
- documents.each.with_index(1).map do |document, index|
- data = {
- link: {
- text: document["title"],
- path: document["link"],
- data_attributes: data_attributes(document["link"], document["title"], index, "ImageCardClicked")
- },
- metadata: {
- document_type: document_type(document),
- public_updated_at: updated_date(document)
- },
- image: {
- url: image_url(document),
- context: context(document)
- }
- }
-
- data
- end
- end
-
- def image_url(document)
- document["image_url"] || PLACEHOLDER_IMAGE
- end
-
- def context(document)
- "#{document_type(document)} - #{updated_date(document).strftime('%e %B %Y')}"
- end
- end
-end
diff --git a/app/presenters/supergroups/policy_and_engagement.rb b/app/presenters/supergroups/policy_and_engagement.rb
deleted file mode 100644
index f773c31da..000000000
--- a/app/presenters/supergroups/policy_and_engagement.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-module Supergroups
- class PolicyAndEngagement < Supergroup
- def initialize(current_path, taxon_ids, filters)
- super(current_path, taxon_ids, filters, MostRecentContent)
- end
- end
-end
diff --git a/app/presenters/supergroups/services.rb b/app/presenters/supergroups/services.rb
deleted file mode 100644
index 1eed005c2..000000000
--- a/app/presenters/supergroups/services.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-module Supergroups
- class Services < Supergroup
- attr_reader :content
-
- def initialize(current_path, taxon_ids, filters)
- super(current_path, taxon_ids, filters, MostPopularContent)
- end
-
- def tagged_content
- format_document_data(@content, data_category: "HighlightBoxClicked")
- end
- end
-end
diff --git a/app/presenters/supergroups/supergroup.rb b/app/presenters/supergroups/supergroup.rb
deleted file mode 100644
index 9560bfe7f..000000000
--- a/app/presenters/supergroups/supergroup.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-module Supergroups
- class Supergroup
- def initialize(current_path, taxon_ids, filters, content_order_class)
- @current_path = current_path
- @taxon_ids = taxon_ids
- @filters = filters.merge(default_filters)
- @content = fetch_content(content_order_class)
- end
-
- def tagged_content
- format_document_data(@content)
- end
-
- private
-
- def format_document_data(documents, data_category: nil, include_timestamp: true)
- # Start with_index at 1 to help align analytics
- documents.each.with_index(1).map do |document, index|
- data = {
- link: {
- text: document["title"],
- path: document["link"],
- data_attributes: data_attributes(document["link"], document["title"], index, data_category)
- },
- metadata: {
- document_type: document_type(document)
- }
- }
-
- if include_timestamp && document["public_timestamp"]
- data[:metadata][:public_updated_at] = updated_date(document)
- end
-
- data
- end
- end
-
- def data_attributes(base_path, link_text, index, data_category)
- {
- track_category: data_module_label + (data_category || "DocumentListClicked"),
- track_action: index,
- track_label: base_path,
- track_options: {
- dimension29: link_text
- }
- }
- end
-
- def document_type(document)
- document["content_store_document_type"].humanize
- end
-
- def updated_date(document)
- Date.parse(document["public_timestamp"])
- end
-
- def data_module_label
- self.class.name.demodulize.camelize(:lower)
- end
-
- def default_filters
- { filter_content_purpose_supergroup: self.class.name.demodulize.underscore }
- end
-
- def fetch_content(content_order_class)
- return [] unless @taxon_ids.any?
- content_order_class.fetch(content_ids: @taxon_ids, current_path: @current_path, filters: @filters)
- end
- end
-end
diff --git a/app/presenters/supergroups/transparency.rb b/app/presenters/supergroups/transparency.rb
deleted file mode 100644
index f7afcbbd4..000000000
--- a/app/presenters/supergroups/transparency.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-module Supergroups
- class Transparency < Supergroup
- def initialize(current_path, taxon_ids, filters)
- super(current_path, taxon_ids, filters, MostRecentContent)
- end
- end
-end
diff --git a/app/services/most_popular_content.rb b/app/services/most_popular_content.rb
deleted file mode 100644
index d9979346b..000000000
--- a/app/services/most_popular_content.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require 'gds_api/rummager'
-
-class MostPopularContent
- include RummagerFields
-
- attr_reader :content_ids, :current_path, :filters, :number_of_links
-
- def initialize(content_ids:, current_path:, filters: {}, number_of_links: 3)
- @content_ids = content_ids
- @current_path = current_path
- @filters = filters
- @number_of_links = number_of_links
- end
-
- def self.fetch(content_ids:, current_path:, filters:)
- new(content_ids: content_ids, current_path: current_path, filters: filters).fetch
- end
-
- def fetch
- search_response["results"]
- rescue GdsApi::HTTPErrorResponse => e
- GovukStatsd.increment("govuk_content_pages.most_popular.#{e.class.name.demodulize.downcase}")
- []
- end
-
-private
-
- def search_response
- params = {
- start: 0,
- count: number_of_links,
- fields: RummagerFields::TAXON_SEARCH_FIELDS,
- filter_part_of_taxonomy_tree: content_ids,
- order: '-popularity',
- reject_link: current_path,
- }
- params[:filter_content_purpose_supergroup] = @filters[:filter_content_purpose_supergroup] if @filters[:filter_content_purpose_supergroup].present?
- params[:filter_content_purpose_subgroup] = @filters[:filter_content_purpose_subgroup] if @filters[:filter_content_purpose_subgroup].present?
-
- Services.rummager.search(params)
- end
-end
diff --git a/app/services/most_recent_content.rb b/app/services/most_recent_content.rb
deleted file mode 100644
index db6eea092..000000000
--- a/app/services/most_recent_content.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-class MostRecentContent
- attr_reader :content_id, :current_path, :filters, :number_of_links
-
- def initialize(content_ids:, current_path:, filters: {}, number_of_links: 3)
- @content_ids = content_ids
- @current_path = current_path
- @filters = filters
- @number_of_links = number_of_links
- end
-
- def self.fetch(content_ids:, current_path:, filters:)
- new(content_ids: content_ids, current_path: current_path, filters: filters).fetch
- end
-
- def fetch
- search_response["results"]
- rescue GdsApi::HTTPErrorResponse => e
- GovukStatsd.increment("govuk_content_pages.most_recent.#{e.class.name.demodulize.downcase}")
- []
- end
-
-private
-
- def search_response
- params = {
- start: 0,
- count: number_of_links,
- fields: RummagerFields::TAXON_SEARCH_FIELDS,
- filter_part_of_taxonomy_tree: @content_ids,
- order: '-public_timestamp',
- reject_link: current_path,
- }
- params[:filter_content_purpose_supergroup] = @filters[:filter_content_purpose_supergroup] if @filters[:filter_content_purpose_supergroup].present?
- params[:filter_content_purpose_subgroup] = @filters[:filter_content_purpose_subgroup] if @filters[:filter_content_purpose_subgroup].present?
-
- Services.rummager.search(params)
- end
-end
diff --git a/app/services/rummager_fields.rb b/app/services/rummager_fields.rb
deleted file mode 100644
index f8969821c..000000000
--- a/app/services/rummager_fields.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module RummagerFields
- TAXON_SEARCH_FIELDS = %w(content_store_document_type
- description
- image_url
- link
- organisations
- public_timestamp
- title).freeze
-
- FEED_SEARCH_FIELDS = %w(title
- link
- description
- display_type
- public_timestamp).freeze
-end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 6802d0d17..282739496 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -24,7 +24,6 @@
<% if @content_item.description %>
<% end %>
- <%= content_pages_nav_test_variant.analytics_meta_tag.html_safe if page_in_scope? %>
<%= yield :extra_head_content %>
@@ -38,61 +37,12 @@
<% if @content_item.try(:back_link) %>
<%= render 'govuk_publishing_components/components/back_link', href: @content_item.back_link %>
- <% elsif show_new_navigation? %>
- <% navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(@content_item.content_item.parsed_content, request) %>
-
- <% if @tagged_taxons.present? || navigation.breadcrumbs.present? %>
-
- <% if @tagged_taxons.present? %>
- <% if @tagged_taxons.one? %>
- <%= render 'govuk_publishing_components/components/breadcrumbs',
- breadcrumbs: navigation.taxon_breadcrumbs[:breadcrumbs],
- collapse_on_mobile: true %>
- <% else %>
- <%= render 'govuk_publishing_components/components/breadcrumbs',
- breadcrumbs: [{ title: "Home", url: "/" }] %>
- <% end %>
- <% elsif navigation.breadcrumbs.present? %>
- <%= render 'govuk_publishing_components/components/breadcrumbs',
- breadcrumbs: navigation.breadcrumbs %>
- <% end %>
-
- <% end %>
-
- <% if @banner_items.present? %>
-
- <% if @banner_items.size <= 2 %>
-
This page is part of <%= @banner_items.take(2).to_sentence.html_safe %>
- <% else %>
- <% featured_banner_link, *other_banner_links = @banner_items %>
-
-
- This page is part of <%= featured_banner_link %>
- and <%= pluralize(other_banner_links.size, 'other') %>
- + show all
-
-
-
- <% end %>
-
- <% end %>
<% else %>
<%= render 'govuk_publishing_components/components/contextual_breadcrumbs', content_item: @content_item.content_item.parsed_content %>
<% end %>
<%= yield %>
- <% if show_new_navigation? && @taxonomy_navigation %>
- <%= render 'shared/taxonomy_navigation',
- taxonomy_navigation: @taxonomy_navigation,
- tagged_taxons: @tagged_taxons,
- related_collections: @related_collections %>
- <% end %>
<%= render 'govuk_publishing_components/components/feedback' %>
diff --git a/app/views/shared/_sidebar_navigation.html.erb b/app/views/shared/_sidebar_navigation.html.erb
index a8d43504e..40a986d08 100644
--- a/app/views/shared/_sidebar_navigation.html.erb
+++ b/app/views/shared/_sidebar_navigation.html.erb
@@ -1,14 +1,7 @@
<%
content_item = @content_item.content_item.parsed_content
-
- if show_new_navigation?
- content_item['links']
- .yield_self { |links| links.except!('document_collections', 'mainstream_browse_pages', 'topics') }
- end
%>
-<% if should_show_sidebar? %>
-
- <%= render 'govuk_publishing_components/components/contextual_sidebar', content_item: content_item %>
-
-<% end %>
+
+ <%= render 'govuk_publishing_components/components/contextual_sidebar', content_item: content_item %>
+
diff --git a/app/views/shared/_taxonomy_navigation.html.erb b/app/views/shared/_taxonomy_navigation.html.erb
deleted file mode 100644
index 7c02b6eb1..000000000
--- a/app/views/shared/_taxonomy_navigation.html.erb
+++ /dev/null
@@ -1,146 +0,0 @@
-<% if taxonomy_navigation.values().flatten.any? %>
-
-
-
- <%= render "govuk_publishing_components/components/heading",
- text: t('supergroups.topics'),
- heading_level: 2,
- font_size: 19
- %>
-
- <% tagged_taxons.each_with_index do |tagged_taxon, index| %>
- -
- <%= link_to(
- tagged_taxon[:taxon_name],
- tagged_taxon[:taxon_link],
- data: {
- "track-category": "relatedTaxonomyLinkClicked",
- "track-action": "1.#{index} Topics",
- "track-label": tagged_taxon[:taxon_link],
- "track-options": {
- dimension29: tagged_taxon[:taxon_name]
- }
- }
- ) %>
-
- <% end %>
-
-
-
- <% if related_collections.any? %>
-
- <%= render "govuk_publishing_components/components/heading",
- text: t('supergroups.collections'),
- heading_level: 2,
- font_size: 19 %>
-
- <% related_collections.each_with_index do |collection, index| %>
- -
- <%= link_to(
- collection[1],
- collection[0],
- data: {
- "track-category": "relatedTaxonomyLinkClicked",
- "track-action": "2.#{index} Collections",
- "track-label": collection[0],
- "track-options": {
- dimension29: collection[1]
- }
- }
- ) %>
-
- <% end %>
-
-
- <% end %>
-
-
- <% if taxonomy_navigation[:services].present? %>
-
- <%= render "govuk_publishing_components/components/heading", {
- text: t('supergroups.services'),
- heading_level: 3,
- font_size: 24,
- margin_bottom: 2
- } %>
-
- <%= render "govuk_publishing_components/components/highlight_boxes", {
- inverse: true,
- items: taxonomy_navigation[:services]
- } %>
-
- <% end %>
-
- <% if taxonomy_navigation[:guidance_and_regulation].present? %>
-
- <%= render "govuk_publishing_components/components/heading", {
- text: t('supergroups.guidance_and_regulation'),
- heading_level: 3,
- font_size: 24,
- margin_bottom: 2
- } %>
-
- <%= render "govuk_publishing_components/components/document_list", {
- items: taxonomy_navigation[:guidance_and_regulation]
- } %>
-
- <% end %>
-
- <% if taxonomy_navigation[:news_and_communications].present? %>
-
- <%= render "govuk_publishing_components/components/heading", {
- text: t('supergroups.news_and_communications'),
- heading_level: 3,
- font_size: 24,
- margin_bottom: 2
- } %>
-
-
- <% taxonomy_navigation[:news_and_communications].each do |promo| %>
- -
- <%= render "govuk_publishing_components/components/image_card", {
- context: promo[:image][:context],
- href: promo[:link][:path],
- heading_text: promo[:link][:text],
- image_src: promo[:image][:url],
- heading_level: 0,
- href_data_attributes: promo[:link][:data_attributes]
- } %>
-
- <% end %>
-
-
- <% end %>
-
- <% if taxonomy_navigation[:policy_and_engagement].present? %>
-
- <%= render "govuk_publishing_components/components/heading", {
- text: t('supergroups.policy_and_engagement'),
- heading_level: 3,
- font_size: 24,
- margin_bottom: 2
- } %>
-
- <%= render "govuk_publishing_components/components/document_list", {
- items: taxonomy_navigation[:policy_and_engagement]
- } %>
-
- <% end %>
-
- <% if taxonomy_navigation[:transparency].present? %>
-
- <%= render "govuk_publishing_components/components/heading", {
- text: t('supergroups.transparency'),
- heading_level: 3,
- font_size: 24,
- margin_bottom: 2
- } %>
-
- <%= render "govuk_publishing_components/components/document_list", {
- items: taxonomy_navigation[:transparency]
- } %>
-
- <% end %>
-
-
-<% end %>
diff --git a/config/application.rb b/config/application.rb
index 127410522..816d8582f 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -49,8 +49,5 @@ class Application < Rails::Application
# Do not swallow errors in after_commit/after_rollback callbacks.
# config.active_record.raise_in_transactional_callbacks = true
-
- # Load links out configuration for taxonomy navigation
- config.taxonomy_navigation_links_out = config_for(:taxonomy_navigation_links_out)
end
end
diff --git a/config/initializers/logstasher.rb b/config/initializers/logstasher.rb
deleted file mode 100644
index 36e2f1b8b..000000000
--- a/config/initializers/logstasher.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-if Object.const_defined?('LogStasher') && LogStasher.enabled
- LogStasher.add_custom_fields do |fields|
- fields[:govuk_content_pages_variant] = request.headers['GOVUK-ABTest-ContentPagesNav']
- end
-end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 1b0a345a7..88fd8f6ad 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -50,15 +50,6 @@ en:
last_updated: "Last updated %{date}"
published: "Published %{date}"
see_all_updates: "see all updates"
- supergroups:
- services: "Services"
- guidance_and_regulation: "Guidance and regulation"
- news_and_communications: "News and communications"
- policy_and_engagement: "Policy and engagement"
- transparency: "Transparency"
- see_more_supergroups: "See more %{supergroup}"
- topics: "Topics"
- collections: "Collections"
language_names:
ar: Arabic
de: German
diff --git a/config/taxonomy_navigation_links_out.yml b/config/taxonomy_navigation_links_out.yml
deleted file mode 100644
index 18f6b5600..000000000
--- a/config/taxonomy_navigation_links_out.yml
+++ /dev/null
@@ -1,104 +0,0 @@
-default: &default
- content_purpose_supergroup:
- news_and_communications:
- - title: policy_and_engagement
- type: content_purpose_supergroup
- supergroup: policy_and_engagement
- - title: research_and_data
- type: content_purpose_subgroup
- supergroup: transparency
- - title: guidance
- type: content_purpose_subgroup
- supergroup: guidance_and_regulation
- - title: news
- type: content_purpose_subgroup
- supergroup: news_and_communications
- - title: incidents
- type: content_purpose_subgroup
- supergroup: transparency
- guidance_and_regulation:
- - title: services
- type: content_purpose_supergroup
- supergroup: services
- - title: guidance
- type: content_purpose_subgroup
- supergroup: guidance_and_regulation
- - title: news
- type: content_purpose_subgroup
- supergroup: news_and_communications
- - title: decisions
- type: content_purpose_subgroup
- supergroup: transparency
- - title: step_by_step
- type: document_type
- supergroup: services
- services:
- - title: services
- type: content_purpose_supergroup
- supergroup: services
- - title: guidance
- type: content_purpose_subgroup
- supergroup: guidance_and_regulation
- content_purpose_subgroup:
- policy:
- - title: policy_and_engagement
- type: content_purpose_supergroup
- supergroup: policy_and_engagement
- - title: policy
- type: content_purpose_subgroup
- supergroup: policy_and_engagement
- incidents:
- - title: incidents
- type: content_purpose_subgroup
- supergroup: transparency
- - title: news
- type: content_purpose_subgroup
- supergroup: news_and_communications
- - title: research_and_data
- type: content_purpose_supergroup
- supergroup: transparency
- - title: guidance
- type: content_purpose_subgroup
- supergroup: guidance_and_regulation
- research_and_data:
- - title: research_and_data
- type: content_purpose_supergroup
- supergroup: transparency
- decisions:
- - title: news
- type: content_purpose_subgroup
- supergroup: news_and_communications
- - title: guidance
- type: content_purpose_subgroup
- supergroup: guidance_and_regulation
- document_type:
- fatality_notice: []
- manual: []
- manual_section: []
- open_consultation:
- - title: policy_and_engagement
- type: content_purpose_supergroup
- supergroup: policy_and_engagement
- - title: decisions
- type: content_purpose_subgroup
- supergroup: transparency
- closed_consultation:
- - title: policy_and_engagement
- type: content_purpose_supergroup
- supergroup: policy_and_engagement
- - title: decisions
- type: content_purpose_subgroup
- supergroup: transparency
- consultation_outcome:
- - title: decisions
- type: content_purpose_subgroup
- supergroup: transparency
-
-development:
- <<: *default
-
-test:
- <<: *default
-
-production:
- <<: *default
\ No newline at end of file
diff --git a/test/controllers/content_pages_nav_ab_testable_test.rb b/test/controllers/content_pages_nav_ab_testable_test.rb
deleted file mode 100644
index c1dc2f458..000000000
--- a/test/controllers/content_pages_nav_ab_testable_test.rb
+++ /dev/null
@@ -1,108 +0,0 @@
-require 'test_helper'
-
-class ContentItemsControllerTest < ActionController::TestCase
- include ContentPagesNavTestHelper
- include GdsApi::TestHelpers::ContentStore
- include GdsApi::TestHelpers::Rummager
- include GovukAbTesting::MinitestHelpers
-
- setup do
- stub_rummager
- end
-
- %w(A B).each do |test_variant|
- test "ContentPagesNav variant #{test_variant} works with a valid taxon" do
- content_item = content_store_has_schema_example("guide", "single-page-guide").tap do |item|
- item["links"]["taxons"] = SINGLE_TAXON
- end
-
- ensure_ab_test_is_correctly_setup(test_variant, content_item)
- end
-
- test "ContentPagesNav variant #{test_variant} works without a valid taxon" do
- content_item = content_store_has_schema_example("guide", "single-page-guide")
-
- @controller.stubs(:page_in_scope?).returns(true)
- ensure_ab_test_is_correctly_setup(test_variant, content_item)
- end
-
- # HTML publications don't use the universal layout so we'll exclude them for now
- test "ContentPagesNav test is inactive for HTML publications (variant #{test_variant})" do
- content_item = content_store_has_schema_example("html_publication", "published").tap do |item|
- item["links"]["taxons"] = SINGLE_TAXON
- end
-
- setup_ab_variant("ContentPagesNav", test_variant)
-
- get :show, params: { path: path_for(content_item) }
-
- assert_response_not_modified_for_ab_test("ContentPagesNav")
- end
-
- test "ContentPagesNav test is inactive when content is not tagged to a live taxon (variant #{test_variant})" do
- content_item = content_store_has_schema_example("guide", "single-page-guide").tap do |item|
- item["links"]["taxons"] = SINGLE_NON_LIVE_TAXON
- end
-
- setup_ab_variant("ContentPagesNav", test_variant)
-
- get :show, params: { path: path_for(content_item) }
-
- assert_response_not_modified_for_ab_test("ContentPagesNav")
- end
- end
-
- test "should_show_sidebar? is true for variant A" do
- content_item = content_store_has_schema_example("guide", "single-page-guide")
- setup_ab_variant("ContentPagesNav", "A")
- get :show, params: { path: path_for(content_item) }
- assert @controller.should_show_sidebar?
- end
-
- test "should_show_sidebar? is true for variant B if the publishing app is not whitehall" do
- content_item = content_store_has_schema_example("guide", "single-page-guide")
- setup_ab_variant("ContentPagesNav", "B")
- get :show, params: { path: path_for(content_item) }
-
- assert @controller.should_show_sidebar?
- end
-
- test "should_show_sidebar? is false for variant B if the publishing app is whitehall" do
- content_item = govuk_content_schema_example("guide", "single-page-guide").merge("publishing_app" => "whitehall")
- content_store_has_item(content_item['base_path'], content_item)
-
- setup_ab_variant("ContentPagesNav", "B")
- get :show, params: { path: path_for(content_item) }
-
- refute @controller.should_show_sidebar?
- end
-
- test "should_show_sidebar? is true when tagged to a step by step even for whitehall content" do
- content_item = content_store_has_schema_example("guide", "guide-with-step-navs").merge("publishing_app" => "whitehall")
- setup_ab_variant("ContentPagesNav", "B")
- get :show, params: { path: path_for(content_item) }
-
- assert @controller.should_show_sidebar?
- end
-
- def ensure_ab_test_is_correctly_setup(test_variant, content_item)
- content_store_has_item(content_item['base_path'], content_item)
-
- @controller.stubs(:page_in_scope?).returns(true)
-
- with_variant ContentPagesNav: test_variant do
- get :show, params: { path: path_for(content_item) }
- assert_response 200
-
- ab_test = GovukAbTesting::AbTest.new("ContentPagesNav", dimension: 65)
- requested = ab_test.requested_variant(request.headers)
- assert requested.variant?(test_variant)
- end
- 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
diff --git a/test/integration/content_pages_navigation_test.rb b/test/integration/content_pages_navigation_test.rb
deleted file mode 100644
index 5e65ae77d..000000000
--- a/test/integration/content_pages_navigation_test.rb
+++ /dev/null
@@ -1,507 +0,0 @@
-require 'test_helper'
-
-class ContentPagesNavigationTest < ActionDispatch::IntegrationTest
- include ContentPagesNavTestHelper
- include GdsApi::TestHelpers::Rummager
-
- def setup
- stub_links_out_supergroups_to_include_all
- end
-
- test "ContentPagesNav variant A does not show taxonomy navigation for single taxon" do
- setup_variant_a
-
- setup_and_visit_content_item_with_taxons('guide', SINGLE_TAXON)
-
- refute page.has_css?('.taxonomy-navigation')
- end
-
- test "ContentPagesNav variant B does not show taxonomy navigation for content not tagged to a taxon" do
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide', [])
-
- refute page.has_css?('.taxonomy-navigation')
- end
-
- test "ContentPagesNav variant B shows taxonomy navigation for single taxon" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide', SINGLE_TAXON)
-
- assert page.has_css?('.taxonomy-navigation li', text: 'Becoming an apprentice')
- assert page.has_css?('.gem-c-highlight-boxes__title', text: 'Free school meals form')
- end
-
- test "ContentPagesNav variant B renders many taxons nicely" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide', THREE_TAXONS)
-
- within '.taxonomy-navigation' do
- assert page.has_css?('li a[href="/education/becoming-an-apprentice"]', text: 'Becoming an apprentice')
- assert page.has_css?('li a[href="/education/becoming-a-wizard"]', text: 'Becoming a wizard')
- assert page.has_css?('li a[href="/education/becoming-the-sorceror-supreme"]', text: 'Becoming the sorceror supreme')
- end
-
- assert page.has_css?('.gem-c-highlight-boxes__title', text: 'Free school meals form')
- end
-
- test "ContentPagesNav variant B only includes live taxons" do
- stub_rummager
- setup_variant_b
-
- taxons = SINGLE_TAXON + SINGLE_NON_LIVE_TAXON
-
- setup_and_visit_content_item_with_taxons('guide', taxons)
-
- within '.taxonomy-navigation' do
- assert page.has_css?('li a[href="/education/becoming-an-apprentice"]', text: 'Becoming an apprentice')
- refute page.has_css?('li a[href="/education/becoming-a-ghostbuster"]', text: 'Becoming a ghostbuster')
- end
- end
-
- test "ContentPagesNav variant A shows sidebar" do
- stub_rummager
- setup_sidebar_variant_a
-
- setup_and_visit_content_from_publishing_app(publishing_app: 'publisher')
- assert page.has_css?('.gem-c-contextual-sidebar')
- end
-
- test "ContentPagesNav variant B hides sidebar" do
- stub_rummager
- setup_sidebar_variant_b
-
- setup_and_visit_content_from_publishing_app(publishing_app: 'whitehall')
- refute page.has_css?('.gem-c-contextual-sidebar')
- end
-
- test "shows the Services section title and documents with tracking" do
- stub_rummager
- stub_empty_guidance
- stub_empty_news
- stub_empty_policies
- stub_empty_transparency
- setup_variant_b
-
- taxons = SINGLE_TAXON
-
- setup_and_visit_content_item_with_taxons('guide', taxons)
-
- assert page.has_css?('h3', text: "Services")
- assert page.has_css?('.gem-c-highlight-boxes__title', text: 'Free school meals form')
- assert page.has_css?('.gem-c-highlight-boxes__title[data-track-category="servicesHighlightBoxClicked"]', text: 'Free school meals form')
- assert page.has_css?('.gem-c-highlight-boxes__title[data-track-action="1"]', text: 'Free school meals form')
- assert page.has_css?('.gem-c-highlight-boxes__title[data-track-label="/government/publications/meals"]', text: 'Free school meals form')
- end
-
- test "does not show the Services section if there is no tagged content" do
- stub_empty_rummager
- setup_variant_b
-
- taxons = SINGLE_TAXON
-
- setup_and_visit_content_item_with_taxons('guide', taxons)
-
- refute page.has_css?('h3', text: "Services")
- end
-
- test "shows the Policy section title and documents with tracking" do
- stub_rummager
- stub_empty_guidance
- stub_empty_news
- stub_empty_services
- stub_empty_transparency
- setup_variant_b
-
- taxons = SINGLE_TAXON
-
- setup_and_visit_content_item_with_taxons('guide', taxons)
-
- assert page.has_css?('h3', text: "Policy and engagement")
-
- assert page.has_css?('.gem-c-document-list__item a[data-track-category="policyAndEngagementDocumentListClicked"]', text: 'Free school meals form')
- assert page.has_css?('.gem-c-document-list__item a[data-track-action="1"]', text: 'Free school meals form')
- assert page.has_css?('.gem-c-document-list__item a[data-track-label="/government/publications/meals"]', text: 'Free school meals form')
- end
-
- test "does not show the Policy section if there is no tagged content" do
- stub_empty_rummager
- setup_variant_b
-
- taxons = SINGLE_TAXON
-
- setup_and_visit_content_item_with_taxons('guide', taxons)
-
- refute page.has_css?('h3', text: "Policy and engagement")
- end
-
- test "shows the Guidance section title and documents with tracking" do
- stub_rummager
- stub_empty_policies
- stub_empty_news
- stub_empty_services
- stub_empty_transparency
- setup_variant_b
-
- taxons = SINGLE_TAXON
-
- setup_and_visit_content_item_with_taxons('guide', taxons)
-
- assert_has_guidance_and_regulation_section
- end
-
- test "does not show the Guidance section if there is no tagged content" do
- stub_empty_rummager
- setup_variant_b
-
- taxons = SINGLE_TAXON
-
- setup_and_visit_content_item_with_taxons('guide', taxons)
-
- refute page.has_css?('h3', text: "Guidance and regulation")
- end
-
- test "shows the Transparency section title and documents with tracking" do
- stub_rummager
- stub_empty_guidance
- stub_empty_news
- stub_empty_policies
- stub_empty_services
- setup_variant_b
-
- taxons = SINGLE_TAXON
-
- setup_and_visit_content_item_with_taxons('guide', taxons)
-
- assert_has_transparency_section
- end
-
- test "does not show the Transparency section if there is no tagged content" do
- stub_empty_rummager
- setup_variant_b
-
- taxons = SINGLE_TAXON
-
- setup_and_visit_content_item_with_taxons('guide', taxons)
-
- refute page.has_css?('h3', text: "Guidance and regulation")
- end
-
- test "shows the News and comms section title and documents with tracking" do
- stub_rummager
- stub_empty_services
- stub_empty_guidance
- stub_empty_policies
- stub_empty_transparency
- setup_variant_b
-
- taxons = SINGLE_TAXON
-
- setup_and_visit_content_item_with_taxons('guide', taxons)
-
- assert_has_news_and_communications_section
- end
-
- test "does not show the News and comms section if there is no tagged content" do
- stub_empty_rummager
- setup_variant_b
-
- taxons = SINGLE_TAXON
-
- setup_and_visit_content_item_with_taxons('guide', taxons)
-
- refute page.has_css?('h3', text: "News and communications")
- end
-
- test "ContentPagesNav variant A shows explore the topic in the sidebar" do
- setup_variant_a
-
- setup_and_visit_content_item('guide')
-
- assert page.has_css?('.gem-c-related-navigation__sub-heading', text: 'Explore the topic')
- end
-
- test "ContentPagesNav variant B does not show explore the topic in the sidebar" do
- setup_variant_b
-
- setup_and_visit_content_item('guide')
-
- refute page.has_css?('.gem-c-related-navigation__sub-heading', text: 'Explore the topic')
- end
-
- test "shows parent-based breadcrumbs if variant a" do
- stub_empty_rummager
- taxons = THREE_TAXONS
- setup_and_visit_content_item_with_taxons('guide', taxons)
-
- within('.gem-c-contextual-breadcrumbs') do
- assert page.has_css?('a', text: "Home")
- assert page.has_css?('a', text: "Childcare and parenting")
- assert page.has_css?('a', text: "Schools and education")
- end
- end
-
- test "ContentPagesNav variant B when a page belongs to a single topic shows full breadcrumb" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide', SINGLE_TAXON)
-
- within('.gem-c-contextual-breadcrumbs') do
- assert page.has_css?('a', text: 'Home')
- assert page.has_css?('a', text: 'Becoming an apprentice')
- end
-
- refute page.has_css?('.taxonomy-navigation__banner')
- end
-
- test "ContentPagesNav variant B shows home breadcrumb when a page belongs to a two topics" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide', TWO_TAXONS)
-
- within('.gem-c-contextual-breadcrumbs') do
- assert page.has_css?('a', text: 'Home')
- refute page.has_css?('a', text: 'Becoming an apprentice')
- refute page.has_css?('a', text: 'Becoming a wizard')
- end
- end
-
- test "ContentPagesNav variant B shows banner when a page belongs to two topics" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide', TWO_TAXONS)
-
- within('.taxonomy-navigation__banner') do
- assert page.has_content?('This page is part of Becoming an apprentice and Becoming a wizard')
- assert page.has_css?('a', text: 'Becoming an apprentice')
- assert page.has_css?('a', text: 'Becoming a wizard')
- end
- end
-
- test "ContentPagesNav variant B shows breadcrumb when a page belongs to more than two topics" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide', THREE_TAXONS)
-
- within('.gem-c-contextual-breadcrumbs') do
- assert page.has_css?('a', text: 'Home')
- refute page.has_css?('a', text: 'Becoming an apprentice')
- refute page.has_css?('a', text: 'Becoming a wizard')
- refute page.has_css?('a', text: 'Becoming the sorceror supreme')
- end
- end
-
- test "ContentPagesNav variant B shows banner when a page belongs to more than two topics" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide', THREE_TAXONS)
-
- within('.taxonomy-navigation__banner') do
- assert page.has_content?('This page is part of Becoming an apprentice and 2 others + show all')
- assert page.has_css?('a', text: 'Becoming an apprentice')
- assert page.has_css?('a', text: 'Becoming a wizard')
- assert page.has_css?('a', text: 'Becoming the sorceror supreme')
- end
- end
-
- test "ContentPagesNav variant B shows full breadcrumb when a page belongs to a single topic and a step by step" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide-with-step-navs', SINGLE_TAXON)
-
- within('.gem-c-contextual-breadcrumbs') do
- assert page.has_css?('a', text: 'Home')
- assert page.has_css?('a', text: 'Becoming an apprentice')
- end
- end
-
- test "ContentPagesNav variant B shows banner when a page belongs to a single topic and a step by step" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide-with-step-navs', SINGLE_TAXON)
-
- within('.taxonomy-navigation__banner') do
- assert page.has_content?('This page is part of Learn to drive a car: step by step')
- assert page.has_css?('a', text: 'Learn to drive a car: step by step')
- end
- end
-
- test "ContentPagesNav variant B has tracking on banner links for single topic and a step by step" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide-with-step-navs', SINGLE_TAXON)
-
- within('.taxonomy-navigation__banner') do
- assert page.has_css?('a[data-track-category="relatedTaxonomyLinkClicked"]', text: 'Learn to drive a car: step by step')
- assert page.has_css?('a[data-track-action="1.1 Step by Step"]', text: 'Learn to drive a car: step by step')
- assert page.has_css?('a[data-track-label="/learn-to-drive-a-car"]')
- end
- end
-
- test "ContentPagesNav variant B shows home breadcrumb when a page belongs to two topics and a step by step" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide-with-step-navs', TWO_TAXONS)
-
- within('.gem-c-contextual-breadcrumbs') do
- assert page.has_css?('a', text: 'Home')
- refute page.has_css?('a', text: 'Becoming an apprentice')
- refute page.has_css?('a', text: 'Becoming a wizard')
- end
- end
-
- test "ContentPagesNav variant B shows banner when a page belongs to two topics and a step by step" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide-with-step-navs', TWO_TAXONS)
-
- within('.taxonomy-navigation__banner') do
- assert page.has_content?('This page is part of Learn to drive a car: step by step and 2 others + show all')
- assert page.has_content?('Becoming an apprentice and Becoming a wizard')
- assert page.has_css?('a', text: 'Learn to drive a car')
- assert page.has_css?('a', text: 'Becoming an apprentice')
- assert page.has_css?('a', text: 'Becoming a wizard')
- end
- end
-
- test "ContentPagesNav variant B has tracking on banner links for two topics and a step by step" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide-with-step-navs', TWO_TAXONS)
-
- within('.taxonomy-navigation__banner') do
- assert page.has_css?('a[data-track-category="relatedTaxonomyLinkClicked"]', text: 'Learn to drive a car: step by step')
- assert page.has_css?('a[data-track-action="1.1 Step by Step"]', text: 'Learn to drive a car: step by step')
- assert page.has_css?('a[data-track-label="/learn-to-drive-a-car"]')
-
- assert page.has_css?('a[data-track-category="relatedTaxonomyLinkClicked"]', text: 'Becoming an apprentice')
- assert page.has_css?('a[data-track-action="1.1 Taxon"]', text: 'Becoming an apprentice')
- assert page.has_css?('a[data-track-label="/education/becoming-an-apprentice"]')
- end
- end
-
- test "ContentPagesNav variant B shows home breadcrumb when a page belongs to more than two topics and a step by step" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide-with-step-navs', THREE_TAXONS)
-
- within('.gem-c-contextual-breadcrumbs') do
- assert page.has_css?('a', text: 'Home')
- refute page.has_css?('a', text: 'Becoming an apprentice')
- refute page.has_css?('a', text: 'Becoming a wizard')
- refute page.has_css?('a', text: 'Becoming the sorceror supreme')
- end
- end
-
- test "ContentPagesNav variant B shows banner when a page belongs to more than two topics and a step by step" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide-with-step-navs', THREE_TAXONS)
-
- within('.taxonomy-navigation__banner') do
- assert page.has_content?('This page is part of Learn to drive a car: step by step and 3 others + show all')
- assert page.has_content?('Becoming an apprentice, Becoming a wizard, and Becoming the sorceror supreme')
- assert page.has_css?('a', text: 'Learn to drive a car')
- assert page.has_css?('a', text: 'Becoming an apprentice')
- assert page.has_css?('a', text: 'Becoming a wizard')
- assert page.has_css?('a', text: 'Becoming the sorceror supreme')
- end
- end
-
- test "links out will filter out supergroups not in the configuration" do
- stub_rummager
- setup_variant_b
- taxons = THREE_TAXONS
- supergroups.each do |supergroup_to_exclude|
- supergroups_to_include = supergroups.delete_if { |supergroup| supergroup == supergroup_to_exclude }
- stub_links_out_supergroups(supergroups_to_include)
- setup_and_visit_content_item_with_taxons('guide', taxons)
- supergroups_to_include.each do |included_supergroup|
- send("assert_has_#{included_supergroup}_section")
- end
- refute page.has_css?('h3', text: supergroup_to_exclude.humanize)
- end
- end
-
- test "ContentPagesNav variant B shows BETA phase message and survey link" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide', SINGLE_TAXON)
-
- within('.gem-c-phase-banner') do
- assert page.has_css?('.phase-tag', text: 'BETA')
-
- assert page.has_content?('This is a test version of the layout of this page.')
-
- assert page.has_css?('a[href="https://www.smartsurvey.co.uk/s/navigationsurvey2018?c=/national-curriculum"]',
- text: 'Take the survey to help us improve it')
- end
- end
-
- test "ContentPagesNav variant B language is set to en" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('guide', SINGLE_TAXON)
-
- assert page.has_css?('.taxonomy-navigation[lang="en"]')
- end
-
- def stub_empty_services
- Supergroups::Services.any_instance.stubs(:tagged_content).returns({})
- end
-
- def stub_empty_guidance
- Supergroups::GuidanceAndRegulation.any_instance.stubs(:tagged_content).returns([])
- end
-
- def stub_empty_news
- Supergroups::NewsAndCommunications.any_instance.stubs(:tagged_content).returns([])
- end
-
- def stub_empty_policies
- Supergroups::PolicyAndEngagement.any_instance.stubs(:tagged_content).returns([])
- end
-
- def stub_empty_transparency
- Supergroups::Transparency.any_instance.stubs(:tagged_content).returns([])
- end
-
- def setup_variant_a
- ContentItemsController.any_instance.stubs(:show_new_navigation?).returns(false)
- end
-
- def setup_variant_b
- ContentItemsController.any_instance.stubs(:show_new_navigation?).returns(true)
- end
-
- def setup_sidebar_variant_a
- ContentItemsController.any_instance.stubs(:should_show_sidebar?).returns(true)
- end
-
- def setup_sidebar_variant_b
- ContentItemsController.any_instance.stubs(:should_show_sidebar?).returns(false)
- end
-
- def schema_type
- "guide"
- end
-end
diff --git a/test/integration/content_pages_related_navigation_test.rb b/test/integration/content_pages_related_navigation_test.rb
deleted file mode 100644
index 4d9b063bf..000000000
--- a/test/integration/content_pages_related_navigation_test.rb
+++ /dev/null
@@ -1,91 +0,0 @@
-require 'test_helper'
-
-class ContentPagesRelatedNavigationTest < ActionDispatch::IntegrationTest
- include ContentPagesNavTestHelper
- include GdsApi::TestHelpers::Rummager
-
- def setup
- stub_links_out_supergroups_to_include_all
- end
-
- test "ContentPagesNav variant A shows related collections in the sidebar" do
- setup_variant_a
-
- setup_and_visit_content_item('case_study')
-
- assert page.has_css?('.gem-c-related-navigation__sub-heading', text: 'Collection')
- end
-
- test "ContentPagesNav variant B shows tagged taxons in the taxonomy navigation" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('case_study', SINGLE_TAXON)
-
- within '.taxonomy-navigation' do
- assert page.has_css?('.gem-c-heading', text: 'Topics')
- assert page.has_css?('.taxonomy-navigation__list-item a', text: 'Becoming an apprentice')
- assert page.has_css?('.taxonomy-navigation__list-item a[data-track-category="relatedTaxonomyLinkClicked"]', text: 'Becoming an apprentice')
- assert page.has_css?('.taxonomy-navigation__list-item a[data-track-action="1.0 Topics"]', text: 'Becoming an apprentice')
- assert page.has_css?('.taxonomy-navigation__list-item a[data-track-label="/education/becoming-an-apprentice"]')
- end
- end
-
- test "ContentPagesNav variant B shows related collections in the taxonomy navigation" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('case_study', SINGLE_TAXON)
-
- within '.taxonomy-navigation' do
- assert page.has_css?('.gem-c-heading', text: 'Collections')
- assert page.has_css?('.taxonomy-navigation__list-item a', text: 'Work Programme real life stories')
- assert page.has_css?('.taxonomy-navigation__list-item a[data-track-category="relatedTaxonomyLinkClicked"]', text: 'Work Programme real life stories')
- assert page.has_css?('.taxonomy-navigation__list-item a[data-track-action="2.0 Collections"]', text: 'Work Programme real life stories')
- assert page.has_css?('.taxonomy-navigation__list-item a[data-track-label="/government/collections/work-programme-real-life-stories"]')
- end
- end
-
- test "ContentPagesNav variant B does not show related collections in the sidebar" do
- setup_variant_b
-
- setup_and_visit_content_item('case_study')
-
- refute page.has_css?('.gem-c-related-navigation__sub-heading', text: 'Collection')
- end
-
- test "ContentPagesNav variant A does not show collections as publisher metadata" do
- stub_rummager
- setup_variant_a
-
- setup_and_visit_content_item_with_taxons('case_study', SINGLE_TAXON)
-
- within '.app-c-publisher-metadata' do
- refute page.has_css?('.app-c-publisher-metadata__term', text: 'Collections')
- end
- end
-
- test "ContentPagesNav variant B shows collections as publisher metadata" do
- stub_rummager
- setup_variant_b
-
- setup_and_visit_content_item_with_taxons('case_study', SINGLE_TAXON)
-
- within '.app-c-publisher-metadata' do
- assert page.has_css?('.app-c-publisher-metadata__term', text: 'Collections')
- assert page.has_css?('.app-c-publisher-metadata__definition a', text: 'Work Programme real life stories')
- end
- end
-
- def setup_variant_a
- ContentItemsController.any_instance.stubs(:show_new_navigation?).returns(false)
- end
-
- def setup_variant_b
- ContentItemsController.any_instance.stubs(:show_new_navigation?).returns(true)
- end
-
- def schema_type
- "case_study"
- end
-end
diff --git a/test/integration/links_out_config_test.rb b/test/integration/links_out_config_test.rb
deleted file mode 100644
index 7f6da48e9..000000000
--- a/test/integration/links_out_config_test.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-require 'test_helper'
-
-class LinksOutConfigTest < ActionDispatch::IntegrationTest
- include ContentPagesNavTestHelper
- include GdsApi::TestHelpers::Rummager
- include Capybara::Minitest::Assertions
-
- Rails.configuration.taxonomy_navigation_links_out.each do |name, group|
- group.each do |level, rules|
- test "links out configuration for #{name} #{level}" do
- stub_rummager
- setup_variant_b
-
- content_example = get_example_guide_with_single_taxon
- content_example[name] = level
-
- content_store_has_item content_example['base_path'], content_example.to_json
- visit_with_cachebust content_example['base_path']
-
- if rules.empty?
- refute_css '.taxonomy-navigation'
- else
- rules.each do |rule|
- assert_css '.taxonomy-navigation .gem-c-heading', text: rule['supergroup'].humanize
- end
- end
- end
- end
- end
-
- def get_example_guide_with_single_taxon
- get_content_example_by_schema_and_name('guide', 'guide').tap do |item|
- item['content_purpose_subgroup'] = 'guidance'
- item['content_purpose_supergroup'] = 'guidance_and_regulation'
- item['document_type'] = 'guide'
- item['links']['taxons'] = SINGLE_TAXON
- end
- end
-
- def setup_variant_b
- ContentItemsController.any_instance.stubs(:show_new_navigation?).returns(true)
- end
-end
diff --git a/test/presenters/content_item/links_out_test.rb b/test/presenters/content_item/links_out_test.rb
deleted file mode 100644
index 5c9639c26..000000000
--- a/test/presenters/content_item/links_out_test.rb
+++ /dev/null
@@ -1,251 +0,0 @@
-require 'test_helper'
-
-class LinksOutTest < ActiveSupport::TestCase
- def setup
- @links_out = Object.new
- @links_out.extend(ContentItem::LinksOut)
- class << @links_out
- def content_item
- {
- "content_purpose_supergroup" => "guidance_and_regulation",
- "content_purpose_subgroup" => "guidance",
- "document_type" => "guide"
- }
- end
- end
- end
-
- def rules
- {
- "content_purpose_supergroup" => {
- "guidance_and_regulation" => [
- {
- "title" => "link_to_guidance_and_regulation",
- "type" => "content_purpose_supergroup",
- "supergroup" => "services"
- }
- ]
- },
- "content_purpose_subgroup" => {
- "guidance" => [
- {
- "title" => "link_to_guidance",
- "type" => "content_purpose_subgroup",
- "supergroup" => "transparency"
- }
- ]
- },
- "document_type" => {
- "guide" => [
- {
- "title" => "link_to_guide",
- "type" => "document_type",
- "supergroup" => "guidance_and_regulation"
- }
- ]
- }
- }
- end
-
- def other_rules
- {
- "content_purpose_supergroup" => {
- "news_and_communications" => [
- {
- "title" => "link_to_news_and_communications",
- "type" => "content_purpose_supergroup",
- "supergroup" => "news_and_communications"
- }
- ]
- },
- "content_purpose_subgroup" => {
- "news" => [
- {
- "title" => "link_to_news",
- "type" => "content_purpose_subgroup",
- "supergroup" => "news_and_communications"
- }
- ]
- },
- "document_type" => {
- "article" => [
- {
- "title" => "link_to_article",
- "type" => "document_type",
- "supergroup" => "news_and_communications"
- }
- ]
- }
- }
- end
-
- def stub_load_rules(rules)
- Rails.configuration.stubs(:taxonomy_navigation_links_out).returns(rules)
- end
-
- def assert_has_supergroup_rule(rule_set)
- assert rule_set["content_purpose_supergroup"].has_key?("guidance_and_regulation")
- end
-
- def assert_has_subgroup_rule(rule_set)
- assert rule_set["content_purpose_subgroup"].has_key?("guidance")
- end
-
- def assert_has_document_type_rule(rule_set)
- assert rule_set["document_type"].has_key?("guide")
- end
-
- def assert_returns_guide
- assert_equal [{ "title" => "link_to_guide", "type" => "document_type", "supergroup" => "guidance_and_regulation" }], @links_out.links_out
- end
-
- def assert_returns_guidance
- assert_equal %w(guidance), @links_out.links_out_subgroups("guidance_and_regulation")
- end
-
- def assert_returns_guidance_and_regulation
- assert_equal %w(guidance_and_regulation), @links_out.links_out_supergroups
- end
-
- def news_and_communications_rule
- { "title" => "link_to_news_and_communications", "type" => "content_purpose_supergroup", "supergroup" => "news_and_communications" }
- end
-
- def news_rule
- { "title" => "link_to_news", "type" => "content_purpose_subgroup", "supergroup" => "news_and_communications" }
- end
-
- test 'links_out_supergroups returns empty array if the content_item is blank' do
- class << @links_out
- def content_item
- {}
- end
- end
- assert_equal [], @links_out.links_out_supergroups
- end
-
- test 'links_out_supergroups returns empty array if the link rules is blank' do
- stub_load_rules({})
- assert_equal [], @links_out.links_out_supergroups
- end
-
- test 'links_out_supergroups returns empty array if the link does not contain any rules for this content_item' do
- stub_load_rules(other_rules)
- assert_equal [], @links_out.links_out_supergroups
- end
-
- test 'links_out_supergroups returns document type rule if it is defined within rule set' do
- assert_has_supergroup_rule(rules)
- assert_has_subgroup_rule(rules)
- assert_has_document_type_rule(rules)
- stub_load_rules(rules)
- assert_equal %w(guidance_and_regulation), @links_out.links_out_supergroups
- end
-
- test 'links_out_supergroups returns subgroup rule if it is defined within rule set and document_type is not' do
- amended_rules = rules
- amended_rules["document_type"] = nil
- assert_has_supergroup_rule(amended_rules)
- assert_has_subgroup_rule(amended_rules)
- stub_load_rules(amended_rules)
- assert_equal %w(transparency), @links_out.links_out_supergroups
- end
-
- test 'links_out_supergroups returns supergroup rule if it is defined within rule set, document_type and supergroup are not' do
- amended_rules = rules
- amended_rules["content_purpose_subgroup"] = nil
- amended_rules["document_type"] = nil
- assert_has_supergroup_rule(amended_rules)
- stub_load_rules(amended_rules)
- assert_equal %w(services), @links_out.links_out_supergroups
- end
-
- test 'links_out_supergroups returns subgroup rule if it is defined within rule set and document_type does not match' do
- amended_rules = rules
- amended_rules["document_type"] = other_rules["document_type"]
- assert_has_supergroup_rule(amended_rules)
- assert_has_subgroup_rule(amended_rules)
- stub_load_rules(amended_rules)
- assert_equal %w(transparency), @links_out.links_out_supergroups
- end
-
- test 'links_out_supergroups returns supergroup rule if it is defined within rule set, document_type and supergroup do not match' do
- amended_rules = rules
- amended_rules["content_purpose_subgroup"] = other_rules["content_purpose_subgroup"]
- amended_rules["document_type"] = other_rules["document_type"]
- assert_has_supergroup_rule(amended_rules)
- stub_load_rules(amended_rules)
- assert_equal %w(services), @links_out.links_out_supergroups
- end
-
- test 'links_out_supergroups returns nothing if the document type is an empty array' do
- amended_rules = rules
- amended_rules["document_type"] = { "guide" => [] }
- assert_has_supergroup_rule(amended_rules)
- assert_has_subgroup_rule(amended_rules)
- stub_load_rules(amended_rules)
- assert_equal [], @links_out.links_out_supergroups
- end
-
- test 'links_out_supergroups returns correct supergroup names for content_purpose_supergroup rules' do
- amended_rules = rules
- amended_rules["content_purpose_supergroup"]["guidance_and_regulation"] << news_and_communications_rule
- amended_rules["content_purpose_subgroup"] = nil
- amended_rules["document_type"] = nil
-
- stub_load_rules(amended_rules)
- assert_equal %w(services news_and_communications), @links_out.links_out_supergroups
- end
-
- test 'links_out_supergroups returns correct supergroup names for content_purpose_subgroup rules' do
- amended_rules = rules
- amended_rules["content_purpose_subgroup"]["guidance"] << news_and_communications_rule
- amended_rules["document_type"] = nil
- stub_load_rules(amended_rules)
- assert_equal %w(transparency news_and_communications), @links_out.links_out_supergroups
- end
-
- test 'links_out_supergroups returns correct supergroup names for document_type rules' do
- amended_rules = rules
- amended_rules["document_type"]["guide"] << news_and_communications_rule
-
- stub_load_rules(amended_rules)
- assert_equal %w(guidance_and_regulation news_and_communications), @links_out.links_out_supergroups
- end
-
- test 'links_out_subgroups returns correct subgroup names for content_purpose_supergroup rules' do
- amended_rules = rules
- amended_rules["content_purpose_supergroup"]["guidance_and_regulation"] << news_rule
- amended_rules["content_purpose_subgroup"] = nil
- amended_rules["document_type"] = nil
-
- stub_load_rules(amended_rules)
- assert_equal %w(link_to_news), @links_out.links_out_subgroups("news_and_communications")
- end
-
- test 'links_out_subgroups returns no subgroup names if content_purpose_subgroup is not a subgroup of the supergroup' do
- amended_rules = rules
- amended_rules["content_purpose_subgroup"]["guidance"] << news_rule
- amended_rules["document_type"] = nil
-
- stub_load_rules(amended_rules)
- assert_equal [], @links_out.links_out_subgroups("guidance_and_regulation")
- end
-
- test 'links_out_subgroups returns correct subgroup names for content_purpose_subgroup rules' do
- amended_rules = rules
- amended_rules["content_purpose_subgroup"]["guidance"] << news_rule
- amended_rules["document_type"] = nil
-
- stub_load_rules(amended_rules)
- assert_equal %w(link_to_news), @links_out.links_out_subgroups("news_and_communications")
- end
-
- test 'links_out_subgroups returns correct subgroup names for document_type rules' do
- amended_rules = rules
- amended_rules["document_type"]["guide"] << news_rule
-
- stub_load_rules(amended_rules)
- assert_equal %w(link_to_news), @links_out.links_out_subgroups("news_and_communications")
- end
-end
diff --git a/test/presenters/supergroups/guidance_and_regulation_test.rb b/test/presenters/supergroups/guidance_and_regulation_test.rb
deleted file mode 100644
index c2b6a2455..000000000
--- a/test/presenters/supergroups/guidance_and_regulation_test.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require 'test_helper'
-
-class GuidanceAndRegulationTest < ActiveSupport::TestCase
- include RummagerHelpers
-
- test "tagged_content returns empty array if taxon ids is a blank array" do
- guidance_and_regulation = Supergroups::GuidanceAndRegulation.new("/no-particular-page", [], {})
- assert_equal [], guidance_and_regulation.tagged_content
- end
-
- test "tagged_content returns empty array if there are taxon ids but no results" do
- taxon_content_ids = ['any-old-taxon', 'some-other-taxon-id']
-
- stub_most_popular_content("/no-particular-page", taxon_content_ids, 0, "guidance_and_regulation")
- guidance_and_regulation = Supergroups::GuidanceAndRegulation.new("/no-particular-page", [], {})
- assert_equal [], guidance_and_regulation.tagged_content
- end
-
- test "tagged_content returns array with 2 items if there are 2 results" do
- taxon_content_ids = ['any-old-taxon', 'some-other-taxon-id']
-
- stub_most_popular_content("/no-particular-page", taxon_content_ids, 2, "guidance_and_regulation")
- guidance_and_regulation = Supergroups::GuidanceAndRegulation.new("/no-particular-page", taxon_content_ids, {})
- assert_equal 2, guidance_and_regulation.tagged_content.count
- end
-end
diff --git a/test/presenters/supergroups/news_and_communications_test.rb b/test/presenters/supergroups/news_and_communications_test.rb
deleted file mode 100644
index 7193af1c2..000000000
--- a/test/presenters/supergroups/news_and_communications_test.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require 'test_helper'
-
-class NewsAndCommunicationsTest < ActiveSupport::TestCase
- include RummagerHelpers
-
- test "finds no results if taxon ids is a blank array" do
- news_and_comms = Supergroups::NewsAndCommunications.new("/a-random-path", [], {})
- assert_equal [], news_and_comms.tagged_content
- end
-
- test "finds no results if there are taxon ids but no results" do
- taxon_content_ids = ['any-old-taxon', 'some-other-taxon-id']
-
- stub_most_recent_content("/a-random-path", taxon_content_ids, 0, "news_and_communications")
- news_and_comms = Supergroups::NewsAndCommunications.new("/a-random-path", taxon_content_ids, {})
- assert_equal [], news_and_comms.tagged_content
- end
-
- test "Presents 2 items with 2 results" do
- taxon_content_ids = ['any-old-taxon', 'some-other-taxon-id']
- stub_most_recent_content("/a-random-path", taxon_content_ids, 2, "news_and_communications")
-
- news_and_comms = Supergroups::NewsAndCommunications.new("/a-random-path", taxon_content_ids, {})
-
- assert_equal 2, news_and_comms.tagged_content.count
- end
-
- test "promoted content includes placeholder images if the content doesn't have one" do
- placeholder_image = "http://static.test.gov.uk/government/assets/placeholder.jpg"
- stub_rummager_document_without_image_url
-
- news_and_comms = Supergroups::NewsAndCommunications.new("/a-random-path", ['any-old-taxon'], {})
- news_item = news_and_comms.tagged_content.first
-
- assert_equal news_item[:image][:url], placeholder_image
- end
-
- test "promoted content includes the content image URL if the content has one" do
- taxon_content_ids = ['any-old-taxon']
- stub_most_recent_content("/a-random-path", taxon_content_ids, 1, "news_and_communications")
-
- news_and_comms = Supergroups::NewsAndCommunications.new("/a-random-path", taxon_content_ids, {})
- news_item = news_and_comms.tagged_content.first
-
- assert_equal news_item[:image][:url], "https://assets.testing.gov.uk/awesome-pic.jpg"
- end
-end
diff --git a/test/presenters/supergroups/policy_and_engagement_test.rb b/test/presenters/supergroups/policy_and_engagement_test.rb
deleted file mode 100644
index 438ac74c6..000000000
--- a/test/presenters/supergroups/policy_and_engagement_test.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require 'test_helper'
-
-class PolicyAndEngagementTest < ActiveSupport::TestCase
- include RummagerHelpers
-
- test "tagged_content returns empty array if taxon ids is a blank array" do
- policy_and_engagement = Supergroups::PolicyAndEngagement.new("/a-random-path", [], {})
- assert_equal [], policy_and_engagement.tagged_content
- end
-
- test "tagged_content returns empty array if there are taxon ids but no results" do
- taxon_content_ids = ['any-old-taxon', 'some-other-taxon-id']
-
- stub_most_recent_content("/a-random-path", taxon_content_ids, 0, "policy_and_engagement")
- policy_and_engagement = Supergroups::PolicyAndEngagement.new("/a-random-path", [], {})
- assert_equal [], policy_and_engagement.tagged_content
- end
-
- test "tagged_content returns array with 2 items if there are 2 results" do
- taxon_content_ids = ['any-old-taxon', 'some-other-taxon-id']
-
- stub_most_recent_content("/a-random-path", taxon_content_ids, 2, "policy_and_engagement")
- policy_and_engagement = Supergroups::PolicyAndEngagement.new("/a-random-path", taxon_content_ids, {})
- assert_equal 2, policy_and_engagement.tagged_content.count
- end
-end
diff --git a/test/presenters/supergroups/services_test.rb b/test/presenters/supergroups/services_test.rb
deleted file mode 100644
index ffe48b048..000000000
--- a/test/presenters/supergroups/services_test.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require 'test_helper'
-
-class ServicesTest < ActiveSupport::TestCase
- include RummagerHelpers
-
- test "services returns no results if taxon ids is a blank array" do
- services = Supergroups::Services.new("/a-random-path", [], {})
- assert_equal [], services.tagged_content
- end
-
- test "services returns no results if there are taxon ids but no results" do
- taxon_content_ids = ['any-old-taxon', 'some-other-taxon-id']
-
- stub_most_popular_content("/a-random-path", taxon_content_ids, 0, "services")
- services = Supergroups::Services.new("/a-random-path", taxon_content_ids, {})
- assert_equal [], services.tagged_content
- end
-
- test "tagged_content returns hash with with 2 featured items and 0 normal items with 2 results" do
- taxon_content_ids = ['any-old-taxon', 'some-other-taxon-id']
-
- stub_most_popular_content("/a-random-path", taxon_content_ids, 2, "services")
-
- services = Supergroups::Services.new("/a-random-path", taxon_content_ids, {})
-
- assert_equal 2, services.tagged_content.count
- end
-
- test "tagged_content returns hash with with 3 featured items and 2 normal items if there are enough results" do
- taxon_content_ids = ['any-old-taxon', 'some-other-taxon-id']
-
- stub_most_popular_content("/a-random-path", taxon_content_ids, 3, "services")
-
- services = Supergroups::Services.new("/a-random-path", taxon_content_ids, {})
-
- assert_equal 3, services.tagged_content.count
- end
-end
diff --git a/test/presenters/supergroups/transparency_test.rb b/test/presenters/supergroups/transparency_test.rb
deleted file mode 100644
index e8a1c668d..000000000
--- a/test/presenters/supergroups/transparency_test.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require 'test_helper'
-
-class TransparencyTest < ActiveSupport::TestCase
- include RummagerHelpers
-
- test "tagged_content returns empty array if taxon ids is a blank array" do
- policy_and_engagement = Supergroups::Transparency.new("/a-random-path", [], {})
- assert_equal [], policy_and_engagement.tagged_content
- end
-
- test "tagged_content returns empty array if there are taxon ids but no results" do
- taxon_content_ids = ['any-old-taxon', 'some-other-taxon-id']
-
- stub_most_recent_content("/a-random-path", taxon_content_ids, 0, "transparency")
- policy_and_engagement = Supergroups::Transparency.new("/a-random-path", [], {})
- assert_equal [], policy_and_engagement.tagged_content
- end
-
- test "tagged_content returns array with 2 items if there are 2 results" do
- taxon_content_ids = ['any-old-taxon', 'some-other-taxon-id']
-
- stub_most_recent_content("/a-random-path", taxon_content_ids, 2, "transparency")
- policy_and_engagement = Supergroups::Transparency.new("/a-random-path", taxon_content_ids, {})
- assert_equal 2, policy_and_engagement.tagged_content.count
- end
-end
diff --git a/test/services/most_popular_content_test.rb b/test/services/most_popular_content_test.rb
deleted file mode 100644
index 1709b6a7f..000000000
--- a/test/services/most_popular_content_test.rb
+++ /dev/null
@@ -1,127 +0,0 @@
-require 'test_helper'
-
-class MostPopularContentTest < ActiveSupport::TestCase
- include RummagerFields
- include GdsApi::TestHelpers::Rummager
-
- def most_popular_content
- @most_popular_content ||= MostPopularContent.new(
- content_ids: taxon_content_ids,
- current_path: "/how-to-ride-a-bike",
- filters: { filter_content_purpose_supergroup: 'guidance_and_regulation', filter_content_purpose_subgroup: ['guidance'] }
- )
- end
-
- def taxon_content_ids
- ['something-id-like', 'some-other-id']
- end
-
- test 'returns the results from search' do
- search_results = {
- body: {
- 'results' => [
- { 'title' => 'Doc 1' },
- { 'title' => 'A Doc 2' },
- ]
- }.to_json
- }
-
- stub_any_rummager_search.to_return(search_results)
-
- results = most_popular_content.fetch
- assert_equal(results.count, 2)
- end
-
- test 'catches api errors' do
- Services.rummager.stubs(:search).raises(GdsApi::HTTPErrorResponse.new(500))
- results = most_popular_content.fetch
-
- assert_equal(results, [])
- end
-
- test 'starts from the first page' do
- assert_includes_params(start: 0) do
- most_popular_content.fetch
- end
- end
-
- test 'requests three results by default' do
- assert_includes_params(count: 3) do
- most_popular_content.fetch
- end
- end
-
- test 'requests a limited number of fields' do
- fields = RummagerFields::TAXON_SEARCH_FIELDS
-
- assert_includes_params(fields: fields) do
- most_popular_content.fetch
- end
- end
-
- test 'orders the results by popularity in descending order' do
- assert_includes_params(order: '-popularity') do
- most_popular_content.fetch
- end
- end
-
- test 'scopes the results to the current taxon' do
- assert_includes_params(filter_part_of_taxonomy_tree: taxon_content_ids) do
- most_popular_content.fetch
- end
- end
-
- test 'filters content by the requested filter_content_purpose_supergroup' do
- assert_includes_params(filter_content_purpose_supergroup: 'guidance_and_regulation') do
- most_popular_content.fetch
- end
- end
-
- test 'filters content by the requested filter_content_purpose_subgroups' do
- assert_includes_params(filter_content_purpose_subgroup: ['guidance']) do
- most_popular_content.fetch
- end
- end
-
- test 'rejects the originating page from the results' do
- assert_includes_params(reject_link: '/how-to-ride-a-bike') do
- most_popular_content.fetch
- end
- end
-
- def assert_includes_params(expected_params)
- search_results = {
- 'results' => [
- {
- 'title' => 'Doc 1'
- },
- {
- 'title' => 'Doc 2'
- }
- ]
- }
-
- Services.
- rummager.
- stubs(:search).
- with { |params| assert_includes_subhash(expected_params, params) }.
- returns(search_results)
-
- results = yield
-
- assert_equal(results.count, 2)
-
- assert_equal(results.first['title'], 'Doc 1')
- assert_equal(results.last['title'], 'Doc 2')
- end
-
- def assert_includes_subhash(expected_sub_hash, hash)
- expected_sub_hash.each do |key, value|
- assert_equal(
- value,
- hash[key],
- "Expected #{hash} to include #{key} => #{value}"
- )
- end
- end
-end
diff --git a/test/services/most_recent_content_test.rb b/test/services/most_recent_content_test.rb
deleted file mode 100644
index 2a36c1b6e..000000000
--- a/test/services/most_recent_content_test.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-require "test_helper"
-require './test/support/custom_assertions.rb'
-
-class MostRecentContentTest < ActiveSupport::TestCase
- include RummagerHelpers
-
- def most_recent_content
- @most_recent_content ||= MostRecentContent.new(
- content_ids: taxon_content_ids,
- current_path: "/some-path",
- filters: { filter_content_purpose_supergroup: 'guidance_and_regulation', filter_content_purpose_subgroup: ['guidance'] },
- number_of_links: 6
- )
- end
-
- test 'catches api errors' do
- Services.rummager.stubs(:search).raises(GdsApi::HTTPErrorResponse.new(500))
- results = most_recent_content.fetch
-
- assert_equal(results, [])
- end
-
- def taxon_content_ids
- ['c3c860fc-a271-4114-b512-1c48c0f82564', 'ff0e8e1f-4dea-42ff-b1d5-f1ae37807af2']
- end
-
- test "orders the results by popularity in descending order" do
- assert_includes_params(order: '-public_timestamp') do
- most_recent_content.fetch
- end
- end
-
- test "includes taxon ids" do
- assert_includes_params(filter_part_of_taxonomy_tree: taxon_content_ids) do
- most_recent_content.fetch
- end
- end
-
- test "returns number of links" do
- assert_includes_params(count: 6) do
- most_recent_content.fetch
- end
- end
-
- test "filters content by the requested filter_content_purpose_subgroups" do
- assert_includes_params(filter_content_purpose_subgroup: ["guidance"]) do
- most_recent_content.fetch
- end
- end
-
- test "excludes current page" do
- assert_includes_params(reject_link: "/some-path") do
- most_recent_content.fetch
- end
- end
-end
diff --git a/test/support/content_pages_nav_test_helper.rb b/test/support/content_pages_nav_test_helper.rb
deleted file mode 100644
index ebbee4af3..000000000
--- a/test/support/content_pages_nav_test_helper.rb
+++ /dev/null
@@ -1,177 +0,0 @@
-module ContentPagesNavTestHelper
- def stub_rummager
- results = []
-
- 4.times do
- results.push(
- "content_store_document_type": "form",
- "link": "/government/publications/meals",
- "title": "Free school meals form",
- "public_timestamp": "2018-01-02T03:04:05Z",
- "image_url": "https://assets.gov.uk/pertinent-image.gif",
- )
- end
-
- stub_any_rummager_search.to_return(
- body: {
- "results": results,
- "total": 1,
- "start": 0,
- "aggregates": {},
- "suggested_queries": []
- }.to_json
- )
-
- content_store_has_item('/government/publications/meals')
- end
-
- def stub_empty_rummager
- results = []
-
- stub_any_rummager_search.to_return(
- body: {
- "results": results,
- "total": 1,
- "start": 0,
- "aggregates": {},
- "suggested_queries": []
- }.to_json
- )
- end
-
- def setup_and_visit_content_from_publishing_app(publishing_app: nil)
- content_item = GovukSchemas::RandomExample.for_schema(frontend_schema: schema_type) do |payload|
- payload.merge('publishing_app' => publishing_app) unless publishing_app.nil?
- payload
- end
-
- content_id = content_item["content_id"]
- path = content_item["base_path"]
-
- stub_request(:get, %r{#{path}})
- .to_return(status: 200, body: content_item.to_json, headers: {})
- visit path
-
- assert_selector %{meta[name="govuk:content-id"][content="#{content_id}"]}, visible: false
- end
-
- SINGLE_TAXON = [
- {
- "base_path" => "/education/becoming-an-apprentice",
- "content_id" => "ff0e8e1f-4dea-42ff-b1d5-f1ae37807af2",
- "description" => "Pay and conditions, how to apply, become a higher or degree apprentice. Apprenticeship levels, training, find an apprenticeship.",
- "schema_name" => "taxon",
- "title" => "Becoming an apprentice",
- "phase" => "live",
- }
- ].freeze
-
- TWO_TAXONS = [
- {
- "base_path" => "/education/becoming-an-apprentice",
- "content_id" => "ff0e8e1f-4dea-42ff-b1d5-f1ae37807af2",
- "description" => "Pay and conditions, how to apply, become a higher or degree apprentice. Apprenticeship levels, training, find an apprenticeship.",
- "schema_name" => "taxon",
- "title" => "Becoming an apprentice",
- "phase" => "live",
- },
- {
- "base_path" => "/education/becoming-a-wizard",
- "content_id" => "ff0e8e1f-4dea-42ff-b1d5-f1ae37807af3",
- "description" => "Pay and conditions, how to apply, become a higher or degree wizard. Wizard levels, training, find a wizard placement.",
- "schema_name" => "taxon",
- "title" => "Becoming a wizard",
- "phase" => "live",
- }
- ].freeze
-
- THREE_TAXONS = [
- {
- "base_path" => "/education/becoming-an-apprentice",
- "content_id" => "ff0e8e1f-4dea-42ff-b1d5-f1ae37807af2",
- "description" => "Pay and conditions, how to apply, become a higher or degree apprentice. Apprenticeship levels, training, find an apprenticeship.",
- "schema_name" => "taxon",
- "title" => "Becoming an apprentice",
- "phase" => "live",
- },
- {
- "base_path" => "/education/becoming-a-wizard",
- "content_id" => "ff0e8e1f-4dea-42ff-b1d5-f1ae37807af3",
- "description" => "Pay and conditions, how to apply, become a higher or degree wizard. Wizard levels, training, find a wizard placement.",
- "schema_name" => "taxon",
- "title" => "Becoming a wizard",
- "phase" => "live",
- },
- {
- "base_path" => "/education/becoming-the-sorceror-supreme",
- "content_id" => "ff0e8e1f-4dea-42ff-b1d5-f1ae37807af4",
- "description" => "Pay and conditions, how to apply. The astral plane, the mirror dimension, infinity stones.",
- "schema_name" => "taxon",
- "title" => "Becoming the sorceror supreme",
- "phase" => "live",
- }
- ].freeze
-
- SINGLE_NON_LIVE_TAXON = [
- {
- "base_path" => "/education/becoming-a-ghostbuster",
- "content_id" => "ff0e8e1f-4dea-42ff-b1d5-f1ae37807af5",
- "description" => "Pay and conditions, how to apply, use of a proton accelerator.",
- "schema_name" => "taxon",
- "title" => "Becoming a ghostbuster",
- "phase" => "ethereal",
- }
- ].freeze
-
- def stub_links_out_supergroups(supergroups_to_include)
- ContentItemPresenter.any_instance.stubs(:links_out_supergroups).returns(supergroups_to_include)
- end
-
- def stub_links_out_supergroups_to_include_all
- stub_links_out_supergroups(supergroups)
- end
-
- def supergroups
- %w(services guidance_and_regulation news_and_communications policy_and_engagement transparency)
- end
-
- def assert_has_services_section
- assert page.has_css?('h3', text: "Services")
- assert page.has_css?('.gem-c-highlight-boxes__title', text: 'Free school meals form')
- assert page.has_css?('.gem-c-highlight-boxes__title[data-track-category="servicesHighlightBoxClicked"]', text: 'Free school meals form')
- assert page.has_css?('.gem-c-highlight-boxes__title[data-track-action="1"]', text: 'Free school meals form')
- assert page.has_css?('.gem-c-highlight-boxes__title[data-track-label="/government/publications/meals"]', text: 'Free school meals form')
- end
-
- def assert_has_policy_and_engagement_section
- assert page.has_css?('h3', text: "Policy and engagement")
-
- assert page.has_css?('.gem-c-document-list__item a[data-track-category="policyAndEngagementDocumentListClicked"]', text: 'Free school meals form')
- assert page.has_css?('.gem-c-document-list__item a[data-track-action="1"]', text: 'Free school meals form')
- assert page.has_css?('.gem-c-document-list__item a[data-track-label="/government/publications/meals"]', text: 'Free school meals form')
- end
-
- def assert_has_guidance_and_regulation_section
- assert page.has_css?('h3', text: "Guidance and regulation")
-
- assert page.has_css?('.gem-c-document-list__item a[data-track-category="guidanceAndRegulationDocumentListClicked"]', text: 'Free school meals form')
- assert page.has_css?('.gem-c-document-list__item a[data-track-action="1"]', text: 'Free school meals form')
- assert page.has_css?('.gem-c-document-list__item a[data-track-label="/government/publications/meals"]', text: 'Free school meals form')
- end
-
- def assert_has_transparency_section
- assert page.has_css?('h3', text: "Transparency")
-
- assert page.has_css?('.gem-c-document-list__item a[data-track-category="transparencyDocumentListClicked"]', text: 'Free school meals form')
- assert page.has_css?('.gem-c-document-list__item a[data-track-action="1"]', text: 'Free school meals form')
- assert page.has_css?('.gem-c-document-list__item a[data-track-label="/government/publications/meals"]', text: 'Free school meals form')
- end
-
- def assert_has_news_and_communications_section
- assert page.has_css?('h3', text: "News and communications")
- assert page.has_css?('ul li .gem-c-image-card__title', text: 'Free school meals form')
- assert page.has_css?('ul li .gem-c-image-card__title-link[data-track-category="newsAndCommunicationsImageCardClicked"]', text: 'Free school meals form')
- assert page.has_css?('ul li .gem-c-image-card__title-link[data-track-action="1"]', text: 'Free school meals form')
- assert page.has_css?('ul li .gem-c-image-card__title-link[data-track-label="/government/publications/meals"]', text: 'Free school meals form')
- end
-end
diff --git a/test/support/rummager_helpers.rb b/test/support/rummager_helpers.rb
deleted file mode 100644
index 773057d7a..000000000
--- a/test/support/rummager_helpers.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-module RummagerHelpers
- def stub_most_recent_content(reject_link, taxon_content_ids, content_link_count, supergroup)
- results = generate_search_results(content_link_count, supergroup)
- stub_for_taxon_and_supergroup(reject_link, taxon_content_ids, results, supergroup, "-public_timestamp")
- end
-
- def stub_most_popular_content(reject_link, taxon_content_ids, content_link_count, supergroup)
- results = generate_search_results(content_link_count, supergroup)
- stub_for_taxon_and_supergroup(reject_link, taxon_content_ids, results, supergroup, "-popularity")
- end
-
- def stub_rummager_document_without_image_url
- result = rummager_document_for_supergroup_section("doc-with-no-url", "news_story", false)
- Services.rummager.stubs(:search)
- .returns(
- "results" => [result],
- "start" => 0,
- "total" => 1
- )
- end
-
- def stub_for_taxon_and_supergroup(reject_link, content_ids, results, filter_content_purpose_supergroup, order_by)
- fields = %w(
- content_store_document_type
- description
- image_url
- link
- organisations
- public_timestamp
- title
- )
-
- params = {
- start: 0,
- count: 3,
- fields: fields,
- filter_part_of_taxonomy_tree: content_ids,
- order: order_by,
- filter_content_purpose_supergroup: filter_content_purpose_supergroup,
- reject_link: reject_link,
- }
-
- Services.rummager.stubs(:search)
- .with(params)
- .returns(
- "results" => results,
- "start" => 0,
- "total" => results.size
- )
- end
-
- def generate_search_results(count, supergroup)
- count.times.map do |number|
- rummager_document_for_supergroup_section("content-item-#{number}", supergroup)
- end
- end
-
- def rummager_document_for_supergroup_section(slug, content_store_document_type, with_image_url = true)
- document = {
- 'title' => slug.titleize.humanize.to_s,
- 'link' => "/#{slug}",
- 'description' => 'A description about tagged content',
- 'content_store_document_type' => content_store_document_type,
- 'public_timestamp' => 1.hour.ago.iso8601,
- 'organisations' => [{ 'title' => "#{content_store_document_type.humanize} Organisation Title" }]
- }
- document['image_url'] = 'https://assets.testing.gov.uk/awesome-pic.jpg' if with_image_url
- document
- end
-
- def assert_includes_params(expected_params)
- search_results = {
- 'results' => [
- {
- 'title' => 'Doc 1'
- },
- {
- 'title' => 'Doc 2'
- }
- ]
- }
-
- Services.
- rummager.
- stubs(:search).
- with { |params| assert_includes_subhash(expected_params, params) }.
- returns(search_results)
-
- results = yield
-
- assert_equal(results.count, 2)
-
- assert_equal(results.first["title"], 'Doc 1')
- assert_equal(results.last["title"], 'Doc 2')
- end
-end