Skip to content

Commit

Permalink
Remove specialist topics
Browse files Browse the repository at this point in the history
  • Loading branch information
unoduetre committed May 13, 2024
1 parent e20f5a3 commit 63906df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def contains_supported_attribute?(tags_hash)
# let through anything for which Whitehall would have sent emails to
# organisation-based lists if none of these other attributes exist on it.
supported_attributes = %w[
topics
policies
service_manual_topics
taxons
Expand Down
22 changes: 11 additions & 11 deletions spec/models/email_alert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"details" => {
"tags" => {
"browse_pages" => ["tax/vat"],
"topics" => ["oil-and-gas/licensing"],
"policies" => ["oil-and-gas/licensing"],
"some_other_missing_tags" => [],
},
"change_history" => [
Expand Down Expand Up @@ -110,7 +110,7 @@ def stub_create_content_change
"publishing_app" => "Whitehall",
"tags" => {
"browse_pages" => ["tax/vat"],
"topics" => ["oil-and-gas/licensing"],
"policies" => ["oil-and-gas/licensing"],
},
"links" => {},
"document_type" => "example_document",
Expand All @@ -128,13 +128,13 @@ def stub_create_content_change
before do
document.merge!(
"links" => {
"topics" => %w[uuid-888],
"organisations" => %w[uuid-888],
},
"expanded_links" => {
"topics" => [
"organisations" => [
{
"content_id" => "uuid-888",
"title" => "This topic",
"title" => "This policy",
},
],
},
Expand All @@ -144,20 +144,20 @@ def stub_create_content_change
it "formats the message to include the parent link" do
expect(email_alert.format_for_email_api).to include(
"links" => {
"topics" => %w[uuid-888],
"organisations" => %w[uuid-888],
},
)
end
end

context "blank tags are present" do
before do
document["links"] = { "topics" => [] }
document["details"]["tags"].merge!("topics" => [])
document["links"] = { "organisations" => [] }
document["details"]["tags"].merge!("policies" => [])
end

it "strips these out" do
expect(email_alert.format_for_email_api["tags"]).not_to include("topics")
expect(email_alert.format_for_email_api["tags"]).not_to include("policies")
end
end

Expand Down Expand Up @@ -206,7 +206,7 @@ def stub_create_content_change
"title" => "Document Collection Title",
"links" => { "documents" => [{ "content_id" => content_id, "links" => {} }] } },
],
"policies" => [
"organisations" => [
{ "content_id" => "uuid-of-policy-paper",
"title" => "Policy Paper Title",
"links" => { "working_groups" => [{ "content_id" => content_id, "links" => {} }] } },
Expand All @@ -223,7 +223,7 @@ def stub_create_content_change
it "formats the message to include content ids of all the reverse linked documents except available_translations" do
expected = {
"document_collections" => %w[uuid-of-document-collection],
"policies" => %w[uuid-of-policy-paper],
"organisations" => %w[uuid-of-policy-paper],
}

expect(email_alert.format_for_email_api["links"]).to eq(expected)
Expand Down
17 changes: 6 additions & 11 deletions spec/models/major_change_message_processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
"details" => {
"change_history" => change_history,
"tags" => {
"topics" => ["example topic"],
"policies" => ["example policy"],
},
},
"links" => {
"topics" => %w[example-topic-uuid],
"organisations" => %w[example-policy-uuid],
},
}
end
Expand All @@ -76,11 +76,6 @@ def email_was_not_triggered
end

context "document tagged with a policy" do
before do
good_document["details"]["tags"] = { "policies" => ["example policy"] }
good_document["links"] = { "policies" => %w[example-policy-uuid] }
end

it "acknowledges and triggers the email" do
processor.process(message)

Expand All @@ -104,7 +99,7 @@ def email_was_not_triggered

context "document with no tags in its links hash" do
before do
good_document["links"].delete("topics")
good_document["links"].delete("organisations")
end

it "still acknowledges and triggers the email" do
Expand All @@ -117,8 +112,8 @@ def email_was_not_triggered

context "document with empty tags" do
before do
good_document["details"]["tags"] = { "topics" => [] }
good_document["links"] = { "topics" => [] }
good_document["details"]["tags"] = { "policies" => [] }
good_document["links"] = { "organisations" => [] }
end

it "acknowledges but doesn't trigger the email" do
Expand All @@ -131,7 +126,7 @@ def email_was_not_triggered

context "document with missing tag fields" do
before do
good_document["links"].delete("topics")
good_document["links"].delete("organisations")
good_document["details"].delete("tags")
end

Expand Down

0 comments on commit 63906df

Please sign in to comment.