Skip to content

Commit

Permalink
Hide section when no tagged services
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanita Barrett committed Jul 24, 2018
1 parent 09b8789 commit 0edddd7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/content_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def load_taxonomy_navigation
services = Supergroups::Services.new(taxon_ids)

@taxonomy_navigation = {
services: services.all_services,
services: (services.all_services if services.any_services?),
}

@tagged_taxons = taxons.map do |taxon|
Expand Down
4 changes: 4 additions & 0 deletions app/presenters/supergroups/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def all_services
}
end

def any_services?
@content.any?
end

def tagged_content
items = @content.drop(promoted_content_count)
format_document_data(items)
Expand Down
11 changes: 11 additions & 0 deletions test/integration/content_pages_navigation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ class ContentPagesNavigationTest < ActionDispatch::IntegrationTest
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 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

def setup_variant_a
ContentItemsController.any_instance.stubs(:show_new_navigation?).returns(false)
end
Expand Down
14 changes: 14 additions & 0 deletions test/support/content_pages_nav_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ def stub_rummager
)
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

SINGLE_TAXON = [
{
"base_path" => "/education/becoming-an-apprentice",
Expand Down

0 comments on commit 0edddd7

Please sign in to comment.