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 topics from email-alert-service #732

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
24 changes: 11 additions & 13 deletions spec/models/email_alert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"details" => {
"tags" => {
"browse_pages" => ["tax/vat"],
"topics" => ["oil-and-gas/licensing"],
hannako marked this conversation as resolved.
Show resolved Hide resolved
"some_other_missing_tags" => [],
},
"change_history" => [
Expand Down Expand Up @@ -110,7 +109,6 @@ def stub_create_content_change
"publishing_app" => "Whitehall",
"tags" => {
"browse_pages" => ["tax/vat"],
"topics" => ["oil-and-gas/licensing"],
hannako marked this conversation as resolved.
Show resolved Hide resolved
},
"links" => {},
"document_type" => "example_document",
Expand All @@ -128,13 +126,13 @@ def stub_create_content_change
before do
document.merge!(
"links" => {
KludgeKML marked this conversation as resolved.
Show resolved Hide resolved
"topics" => %w[uuid-888],
"world_locations" => %w[uuid-888],
},
"expanded_links" => {
"topics" => [
"world_locations" => [
{
"content_id" => "uuid-888",
"title" => "This topic",
"title" => "This world location",
},
],
},
Expand All @@ -144,20 +142,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],
"world_locations" => %w[uuid-888],
},
)
end
end

context "blank tags are present" do
before do
document["links"] = { "topics" => [] }
document["details"]["tags"].merge!("topics" => [])
document["links"] = { "world_locations" => [] }
document["details"]["tags"].merge!("roles" => [])
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("roles")
end
end

Expand Down Expand Up @@ -206,9 +204,9 @@ def stub_create_content_change
"title" => "Document Collection Title",
"links" => { "documents" => [{ "content_id" => content_id, "links" => {} }] } },
],
"policies" => [
{ "content_id" => "uuid-of-policy-paper",
"title" => "Policy Paper Title",
"world_locations" => [
{ "content_id" => "uuid-of-location",
"title" => "World Location Title",
"links" => { "working_groups" => [{ "content_id" => content_id, "links" => {} }] } },
],
"available_translations" => [
Expand All @@ -223,7 +221,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],
"world_locations" => %w[uuid-of-location],
}

expect(email_alert.format_for_email_api["links"]).to eq(expected)
Expand Down
19 changes: 7 additions & 12 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"],
"roles" => %w[prime-minister],
},
},
"links" => {
"topics" => %w[example-topic-uuid],
"world_locations" => %w[example-location-uuid],
},
}
end
Expand All @@ -75,12 +75,7 @@ def email_was_not_triggered
message_acknowledged
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

context "document tagged with a role" do
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("world_locations")
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"] = { "roles" => [] }
good_document["links"] = { "world_locations" => [] }
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("world_locations")
good_document["details"].delete("tags")
end

Expand Down
Loading