Skip to content

Commit

Permalink
Remove specialist topics from specs
Browse files Browse the repository at this point in the history
  • Loading branch information
unoduetre committed May 13, 2024
1 parent 1b42485 commit b8bb846
Show file tree
Hide file tree
Showing 24 changed files with 215 additions and 201 deletions.
2 changes: 1 addition & 1 deletion spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
factory :subscriber_list do
sequence(:title) { |n| "title #{n}" }
sequence(:slug) { |n| "title-#{n}" }
tags { { topics: { any: ["motoring/road_rage"] } } }
tags { { tribunal_decision_categories: { any: ["motoring/road_rage"] } } }
created_at { 1.year.ago }

trait :travel_advice do
Expand Down
8 changes: 4 additions & 4 deletions spec/features/daily_digest_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
RSpec.describe "Daily digests", type: :request do
let(:list_one_topic_id) { "0eb5d0f0-d384-4f27-9da8-3f9e9b22a820" }
let(:list_one_taxon_id) { "0eb5d0f0-d384-4f27-9da8-3f9e9b22a820" }
let(:list_two_taxon_id) { "6416e4e0-c0c1-457a-8337-4bf8ed9d5f80" }

let(:subscriber_list_one) do
create_subscriber_list(
title: "Subscriber list one",
links: {
topics: { any: [list_one_topic_id] },
document_collections: { any: [list_one_taxon_id] },
},
)
end
Expand Down Expand Up @@ -36,7 +36,7 @@
description: "Description one",
change_note: "Change note one",
public_updated_at: "2017-01-01 10:00:00",
links: { topics: [list_one_topic_id] },
links: { document_collections: [list_one_taxon_id] },
)
end

Expand Down Expand Up @@ -71,7 +71,7 @@
)

travel_to(Time.zone.parse("2017-01-01 09:30")) do
create_content_change(links: { topics: [list_one_topic_id] })
create_content_change(links: { document_collections: [list_one_taxon_id] })
end

travel_to(Time.zone.parse("2017-01-01 09:32")) do
Expand Down
8 changes: 4 additions & 4 deletions spec/features/weekly_digest_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
RSpec.describe "Weekly digests", type: :request do
let(:list_one_topic_id) { "0eb5d0f0-d384-4f27-9da8-3f9e9b22a820" }
let(:list_one_taxon_id) { "0eb5d0f0-d384-4f27-9da8-3f9e9b22a820" }
let(:list_two_taxon_id) { "6416e4e0-c0c1-457a-8337-4bf8ed9d5f80" }

let(:subscriber_list_one) do
create_subscriber_list(
title: "Subscriber list one",
links: {
topics: { any: [list_one_topic_id] },
document_collections: { any: [list_one_taxon_id] },
},
)
end
Expand Down Expand Up @@ -39,7 +39,7 @@
change_note: "Change note one",
public_updated_at: "2017-01-01 10:00:00",
links: {
topics: [list_one_topic_id],
document_collections: [list_one_taxon_id],
},
)
end
Expand Down Expand Up @@ -75,7 +75,7 @@
)

travel_to(Time.zone.parse("2017-01-01 09:30")) do
create_content_change(links: { topics: [list_one_topic_id] })
create_content_change(links: { document_collections: [list_one_taxon_id] })
end

travel_to(Time.zone.parse("2017-01-04 09:32")) do
Expand Down
18 changes: 9 additions & 9 deletions spec/integration/browsing_subscriber_lists_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
create(
:subscriber_list,
links: {
topics: { any: [uuid, "drug-device-alert"] },
taxon_tree: { any: [uuid, "drug-device-alert"] },
},
tags: {},
document_type: "",
Expand All @@ -23,7 +23,7 @@
:subscriber_list,
links: {},
tags: {
topics: { any: ["oil-and-gas/licensing", "drug-device-alert"] },
tribunal_decision_categories: { any: ["oil-and-gas/licensing", "drug-device-alert"] },
},
document_type: "",
)
Expand All @@ -42,15 +42,15 @@
create(
:subscriber_list,
links: {
topics: { any: %w[vat-rates] },
taxon_tree: { any: %w[vat-rates] },
},
tags: {},
document_type: "tax",
)
end

it "responds with the matching subscriber list" do
get_subscriber_list(links: { topics: { any: [uuid, "drug-device-alert"] } })
get_subscriber_list(links: { taxon_tree: { any: [uuid, "drug-device-alert"] } })
database_subscriber_list = subscriber_list_links_only

expect(response_subscriber_list).to include(
Expand All @@ -64,13 +64,13 @@
end

it "finds subscriber lists that match all of the links" do
get_subscriber_list(links: { topics: { any: [uuid, "drug-device-alert"] } })
get_subscriber_list(links: { taxon_tree: { any: [uuid, "drug-device-alert"] } })
expect(response.status).to eq(200)
expect(response_subscriber_list[:id]).to eq(subscriber_list_links_only.id)
end

it "finds subscriber lists that match all of the tags" do
get_subscriber_list(tags: { topics: { any: ["drug-device-alert", "oil-and-gas/licensing"] } })
get_subscriber_list(tags: { tribunal_decision_categories: { any: ["drug-device-alert", "oil-and-gas/licensing"] } })
expect(response.status).to eq(200)
expect(response_subscriber_list[:id]).to eq(subscriber_list_tags_only.id)
end
Expand All @@ -83,7 +83,7 @@

it "finds subscriber lists that match links and document type" do
get_subscriber_list(
links: { topics: { any: %w[vat-rates] } },
links: { taxon_tree: { any: %w[vat-rates] } },
document_type: "tax",
)
expect(response.status).to eq(200)
Expand All @@ -96,10 +96,10 @@
end

it "copes if the (legacy) links / tags are not in a hash" do
get_subscriber_list(links: { topics: [uuid, "drug-device-alert"] })
get_subscriber_list(links: { taxon_tree: [uuid, "drug-device-alert"] })
expect(response_subscriber_list[:id]).to eq(subscriber_list_links_only.id)

get_subscriber_list(tags: { topics: ["drug-device-alert", "oil-and-gas/licensing"] })
get_subscriber_list(tags: { tribunal_decision_categories: ["drug-device-alert", "oil-and-gas/licensing"] })
expect(response_subscriber_list[:id]).to eq(subscriber_list_tags_only.id)
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/integration/create_subscriber_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

expect(subscriber_list).to include(
"tags" => {
"topics" => {
"tribunal_decision_categories" => {
"any" => ["oil-and-gas/licensing"],
},
"location" => {
"all" => %w[france germany],
},
},
"links" => {
"topics" => {
"document_collections" => {
"any" => %w[uuid-888],
},
"taxon_tree" => {
Expand All @@ -44,7 +44,7 @@
it "converts them to a nested hash" do
create_subscriber_list(
tags: { location: %w[france germany] },
links: { topics: %w[uuid-888] },
links: { document_collections: %w[uuid-888] },
)

expect(response_subscriber_list).to include(
Expand All @@ -54,7 +54,7 @@
},
},
"links" => {
"topics" => {
"document_collections" => {
"any" => %w[uuid-888],
},
},
Expand Down Expand Up @@ -115,11 +115,11 @@ def create_subscriber_list(payload = {})
defaults = {
title: "This is a sample title",
tags: {
topics: { any: ["oil-and-gas/licensing"] },
tribunal_decision_categories: { any: ["oil-and-gas/licensing"] },
location: { all: %w[france germany] },
},
links: {
topics: { any: %w[uuid-888] },
document_collections: { any: %w[uuid-888] },
taxon_tree: { all: %w[taxon1 taxon2] },
},
}
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/send_content_change_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
subject: "This is a subject",
body: "body stuff",
tags: {
topics: ["oil-and-gas/licensing"],
tribunal_decision_categories: ["oil-and-gas/licensing"],
},
links: {
organisations: %w[
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/email_alert_criteria_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
end

context "when the content item is valid because it contains a supported link type" do
let!(:content_item) { valid_content_item_no_parent.merge("links" => { "topics" => [{ "locale" => "en" }] }) }
let!(:content_item) { valid_content_item_no_parent.merge("links" => { "taxons" => [{ "locale" => "en" }] }) }

it "should return true" do
expect(subject.would_trigger_alert?).to be true
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/reports/subscriber_lists_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end

it "returns data around active lists for the given date" do
expected_criteria_bits = '{"document_type":"","tags":{"topics":{"any":["motoring/road_rage"]}},' \
expected_criteria_bits = '{"document_type":"","tags":{"tribunal_decision_categories":{"any":["motoring/road_rage"]}},' \
'"links":{},"email_document_supertype":"","government_document_supertype":""}'

expected = CSV.generate do |csv|
Expand Down
10 changes: 5 additions & 5 deletions spec/models/subscriber_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
end

it "is valid when tags 'hash' has 'any' values that are arrays" do
subject.tags = { topics: { any: %w[bar] } }
subject.tags = { tribunal_decision_categories: { any: %w[bar] } }

expect(subject).to be_valid
end

it "is valid when tags 'hash' has 'all' values that are arrays" do
subject.tags = { topics: { all: %w[bar] } }
subject.tags = { tribunal_decision_categories: { all: %w[bar] } }

expect(subject).to be_valid
end
Expand All @@ -42,7 +42,7 @@
end

it "is invalid when tags 'hash' has values that are not arrays" do
subject.tags = { topics: { any: "bar" } }
subject.tags = { tribunal_decision_categories: { any: "bar" } }

expect(subject).to be_invalid
expect(subject.errors[:tags]).to include("All tag values must be sent as Arrays")
Expand Down Expand Up @@ -128,10 +128,10 @@

describe "#tags" do
it "deserializes the tag arrays" do
list = create(:subscriber_list, tags: { topics: { any: ["environmental-management/boating"], all: ["oil-and-gas/licensing"] } })
list = create(:subscriber_list, tags: { tribunal_decision_categories: { any: ["environmental-management/boating"], all: ["oil-and-gas/licensing"] } })
list.reload

expect(list.tags).to eq(topics: { any: ["environmental-management/boating"], all: ["oil-and-gas/licensing"] })
expect(list.tags).to eq(tribunal_decision_categories: { any: ["environmental-management/boating"], all: ["oil-and-gas/licensing"] })
end
end

Expand Down

0 comments on commit b8bb846

Please sign in to comment.