Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove specialist topic code from Content Tagger #1651

Merged
1 change: 0 additions & 1 deletion app/models/bulk_tagging/bulk_tagging_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ class BulkTaggingSource
def source_name_to_content_key_map
{
document_collection: "documents",
topic: "children",
mainstream_browse_page: "children",
taxon: "taxon",
}
Expand Down
5 changes: 0 additions & 5 deletions app/models/content_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def suggested_related_links?

def denylisted_tag_types
document_denylist = Array(denylist[publishing_app]).map(&:to_sym)
document_denylist += additional_temporary_denylist

unless related_links_are_renderable?
document_denylist += [:ordered_related_items]
Expand Down Expand Up @@ -155,8 +154,4 @@ def related_links_are_renderable?
written_statement
].include?(document_type)
end

def additional_temporary_denylist
publishing_app == "specialist-publisher" && document_type == "finder" ? [:topics] : []
end
end
1 change: 0 additions & 1 deletion app/models/tagging/content_item_expanded_links.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class ContentItemExpandedLinks
suggested_ordered_related_items
mainstream_browse_pages
parent
topics
organisations
meets_user_needs
].freeze
Expand Down
4 changes: 0 additions & 4 deletions app/services/linkables.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Used by Tagging & Bulk Tagging to populate the available tags.
class Linkables
def topics
@topics ||= for_nested_document_type("topic")
end

def taxons(exclude_ids: [], include_draft: true)
@taxons ||= for_document_type("taxon", include_draft:).tap do |items|
if Array(exclude_ids).present?
Expand Down
2 changes: 1 addition & 1 deletion app/views/bulk_tags/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<% end %>

<div class="lead">
Search for a topic, mainstream browse page, taxon, or document collection to
Search for a mainstream browse page, taxon, or document collection to
bulk tag its content.
</div>

Expand Down
15 changes: 0 additions & 15 deletions app/views/taggings/_form_for_topics.html.erb

This file was deleted.

8 changes: 3 additions & 5 deletions config/denylisted_tag_types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ default: &default
- parent

whitehall:
# Specialist topic pages and the parent (breadcrumb) are managed in Whitehall itself. This
# The parent (breadcrumb) is managed in Whitehall itself. This
# will stay that way because Whitehall is too complex to make a half-way
# change to a system where topics and breadcrumb are read & written from
# change to a system where breadcrumb is read & written from
# the publishing-api.
#
# Whitehall does send this information to the publishing-api so it can still
# be used as a source of information.
- parent
- topics

# Organisation tagging is done in Whitehall, because its data model is too
# much intertwined with organisations to make it read/write this tag from
Expand Down Expand Up @@ -54,15 +53,14 @@ development:

test:
<<: *default
test-app-that-can-be-tagged-to-topics-only:
test-app-that-can-be-tagged-to-taxons-only:
- mainstream_browse_pages
- meets_user_needs
- ordered_related_items
- ordered_related_items_overrides
- suggested_ordered_related_items
- organisations
- parent
- taxons

production:
<<: *default
1 change: 0 additions & 1 deletion config/document_types_excluded_from_the_topic_taxonomy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ document_types:
- special_route
- staff_update
- taxon
- topic
- topical_event
- topical_event_about_page
- travel_advice
Expand Down
14 changes: 0 additions & 14 deletions spec/features/bulk_tagging_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@ def given_a_collection_with_items_and_some_other_content_groupings

stub_publishing_api_has_item(document_collection)

publishing_api_has_content_items(
[{
content_id: "topic-id",
title: "A Topic",
base_path: "/a-topic",
document_type: "topic",
}],
q: "topic",
)

publishing_api_has_content_items(
[{
content_id: "browse-page-id",
Expand Down Expand Up @@ -98,10 +88,6 @@ def and_a_set_of_taxons
def when_i_search_for_the_collection
visit new_bulk_tag_path

fill_in "bulk_tag_query", with: "topic"
click_button I18n.t("bulk_tag.search_button")
expect(page).to have_text("A Topic")

fill_in "bulk_tag_query", with: "browse"
click_button I18n.t("bulk_tag.search_button")
expect(page).to have_text("A Mainstream Browse Page")
Expand Down
3 changes: 1 addition & 2 deletions spec/features/related_item_tagging_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def given_a_content_item_exists

def given_we_can_populate_the_dropdowns_with_content_from_publishing_api
# In this test we don't care about empty dropdowns
%w[topic taxon organisation mainstream_browse_page need].each do |document_type|
%w[taxon organisation mainstream_browse_page need].each do |document_type|
stub_publishing_api_has_linkables([], document_type:)
end
end
Expand Down Expand Up @@ -100,7 +100,6 @@ def then_the_publishing_api_is_sent_the_related_item
ordered_related_items: %w[a484eaea-eeb6-48fa-92a7-b67c6cd414f6],
mainstream_browse_pages: [],
parent: [],
topics: [],
organisations: [],
meets_user_needs: [],
)
Expand Down
75 changes: 40 additions & 35 deletions spec/features/tag_a_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

scenario "User looks up and tags a content item" do
given_there_is_a_content_item_with_expanded_links(
topics: [example_topic],
taxons: [example_linked_content],
)

when_i_visit_edit_a_page
Expand All @@ -16,15 +16,15 @@
and_the_expected_navigation_link_is_highlighted
and_i_see_the_taxon_form

when_i_select_an_additional_topic("Business tax / Pension scheme administration")
when_i_select_an_additional_taxon("Vehicle plating")
and_i_submit_the_form

then_the_publishing_api_is_sent(
taxons: [],
taxons: ["17f91fdf-a36f-48f0-989c-a056d56876ee", example_linked_content["content_id"]],
ordered_related_items: [],
ordered_related_items_overrides: [],
mainstream_browse_pages: [],
parent: [],
topics: ["e1d6b771-a692-4812-a4e7-7562214286ef", example_topic["content_id"]],
organisations: [],
meets_user_needs: [],
)
Expand All @@ -34,25 +34,26 @@
given_there_is_a_content_item_with_no_expanded_links
and_i_am_on_the_page_for_the_item

when_i_select_an_additional_topic("Business tax / Pension scheme administration")
when_i_select_an_additional_taxon("Vehicle plating")
and_i_submit_the_form

then_the_publishing_api_is_sent(
taxons: [],
taxons: %w[17f91fdf-a36f-48f0-989c-a056d56876ee],
ordered_related_items: [],
mainstream_browse_pages: [],
parent: [],
topics: %w[e1d6b771-a692-4812-a4e7-7562214286ef],
organisations: [],
meets_user_needs: [],
)
end

scenario "User makes a conflicting change" do
given_there_is_a_content_item_with_expanded_links(topics: [example_topic])
given_there_is_a_content_item_with_expanded_links(
taxons: [example_linked_content],
)
and_i_am_on_the_page_for_the_item

when_i_select_an_additional_topic("Business tax / Pension scheme administration")
when_i_select_an_additional_taxon("Vehicle plating")
and_somebody_else_makes_a_change
and_i_submit_the_form

Expand All @@ -66,17 +67,21 @@
end

scenario "User inputs a correct basepath directly in the URL" do
given_there_is_a_content_item_with_expanded_links(topics: [example_topic])
given_there_is_a_content_item_with_expanded_links(
taxons: [example_linked_content],
)
when_i_type_its_basepath_in_the_url_directly
then_i_am_on_the_page_for_the_item
and_the_expected_navigation_link_is_highlighted
end

context "with javascript disabled", type: :feature, js: false do
scenario "the user sets a new related link" do
given_there_is_a_content_item_with_expanded_links(ordered_related_items: [example_topic])
given_there_is_a_content_item_with_expanded_links(
ordered_related_items: [example_linked_content],
)
stub_publishing_api_has_lookups(
example_topic["base_path"] => example_topic["content_id"],
example_linked_content["base_path"] => example_linked_content["content_id"],
"/pay-vat" => "a484eaea-eeb6-48fa-92a7-b67c6cd414f6",
)
and_i_am_on_the_page_for_the_item
Expand All @@ -85,19 +90,20 @@

then_the_publishing_api_is_sent(
taxons: [],
ordered_related_items: [example_topic["content_id"], "a484eaea-eeb6-48fa-92a7-b67c6cd414f6"],
ordered_related_items: [example_linked_content["content_id"], "a484eaea-eeb6-48fa-92a7-b67c6cd414f6"],
mainstream_browse_pages: [],
parent: [],
topics: [],
organisations: [],
meets_user_needs: [],
)
end

scenario "the user sets an invalid related link" do
given_there_is_a_content_item_with_expanded_links(ordered_related_items: [example_topic])
given_there_is_a_content_item_with_expanded_links(
ordered_related_items: [example_linked_content],
)
stub_publishing_api_has_lookups(
example_topic["base_path"] => example_topic["content_id"],
example_linked_content["base_path"] => example_linked_content["content_id"],
)
and_i_am_on_the_page_for_the_item
when_i_fill_in_related_items(2 => "/pay-cat")
Expand All @@ -108,9 +114,11 @@
end

scenario "the user sets a new valid and invalid related link" do
given_there_is_a_content_item_with_expanded_links(ordered_related_items: [example_topic])
given_there_is_a_content_item_with_expanded_links(
ordered_related_items: [example_linked_content],
)
stub_publishing_api_has_lookups(
example_topic["base_path"] => example_topic["content_id"],
example_linked_content["base_path"] => example_linked_content["content_id"],
"/pay-vat" => "a484eaea-eeb6-48fa-92a7-b67c6cd414f6",
)
and_i_am_on_the_page_for_the_item
Expand All @@ -123,9 +131,11 @@
end

scenario "the user changes a suggested related link to be invalid" do
given_there_is_a_content_item_with_expanded_links(suggested_ordered_related_items: [example_topic])
given_there_is_a_content_item_with_expanded_links(
suggested_ordered_related_items: [example_linked_content],
)
stub_publishing_api_has_lookups(
example_topic["base_path"] => example_topic["content_id"],
example_linked_content["base_path"] => example_linked_content["content_id"],
)
and_i_am_on_the_page_for_the_item
when_i_fill_in_related_items(6 => "/pay-cat")
Expand All @@ -136,9 +146,11 @@
end

scenario "the user removes suggested related links" do
given_there_is_a_content_item_with_expanded_links(suggested_ordered_related_items: [example_topic])
given_there_is_a_content_item_with_expanded_links(
suggested_ordered_related_items: [example_linked_content],
)
stub_publishing_api_has_lookups(
example_topic["base_path"] => example_topic["content_id"],
example_linked_content["base_path"] => example_linked_content["content_id"],
"/pay-vat" => "a484eaea-eeb6-48fa-92a7-b67c6cd414f6",
)
and_i_am_on_the_page_for_the_item
Expand All @@ -150,7 +162,6 @@
suggested_ordered_related_items: [],
mainstream_browse_pages: [],
parent: [],
topics: [],
organisations: [],
meets_user_needs: [],
)
Expand All @@ -159,7 +170,7 @@
scenario "the user does not see suggested related links when no suggested links exist" do
given_there_is_a_content_item_with_expanded_links(ordered_related_items: [])
stub_publishing_api_has_lookups(
example_topic["base_path"] => example_topic["content_id"],
example_linked_content["base_path"] => example_linked_content["content_id"],
"/pay-vat" => "a484eaea-eeb6-48fa-92a7-b67c6cd414f6",
)
and_i_am_on_the_page_for_the_item
Expand Down Expand Up @@ -266,11 +277,11 @@ def and_i_see_the_url_is_invalid
expect(page).to have_content "Not a known URL on GOV.UK"
end

def when_i_select_an_additional_topic(selection)
def when_i_select_an_additional_taxon(selection)
@tagging_request = stub_request(:patch, "#{Plek.find('publishing-api')}/v2/links/MY-CONTENT-ID")
.to_return(status: 200)

select selection, from: "Topics"
select selection, from: "Taxons"
end

def and_somebody_else_makes_a_change
Expand All @@ -296,16 +307,10 @@ def then_the_publishing_api_is_sent(**links)
end

def given_we_can_populate_the_dropdowns_with_content_from_publishing_api
publishing_api_has_topic_linkables(
[
"/topic/id-of-already-tagged",
"/topic/business-tax/pension-scheme-administration",
],
)

publishing_api_has_taxon_linkables(
[
"/alpha-taxonomy/vehicle-plating",
"/alpha-taxonomy/vehicle-weights-explained",
],
)

Expand All @@ -328,9 +333,9 @@ def given_we_can_populate_the_dropdowns_with_content_from_publishing_api
)
end

def example_topic
def example_linked_content
{
"content_id" => "ID-OF-ALREADY-TAGGED",
"content_id" => "4b5e77f7-69e5-45a9-9061-348cdce876fb",
"base_path" => "/already-tagged",
"title" => "Already tagged",
}
Expand Down
Loading
Loading