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 specs #2147

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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: %w[agency-workers] } } }
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_organisation_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] },
organisations: { any: [list_organisation_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: { organisations: [list_organisation_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: { organisations: [list_organisation_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_organisation_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] },
organisations: { any: [list_organisation_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],
organisations: [list_organisation_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: { organisations: [list_organisation_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, "96d2db38-2ddd-4a3c-b9b4-11e310c8f256"] },
},
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: %w[transfer-of-undertakings time-to-train] },
},
document_type: "",
)
Expand All @@ -42,15 +42,15 @@
create(
:subscriber_list,
links: {
topics: { any: %w[vat-rates] },
taxon_tree: { any: %w[642f0671-8521-4210-91d4-9c9c0e4e2187] },
},
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, "96d2db38-2ddd-4a3c-b9b4-11e310c8f256"] } })
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, "96d2db38-2ddd-4a3c-b9b4-11e310c8f256"] } })
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: %w[time-to-train transfer-of-undertakings] } })
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[642f0671-8521-4210-91d4-9c9c0e4e2187] } },
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, "96d2db38-2ddd-4a3c-b9b4-11e310c8f256"] })
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: %w[time-to-train transfer-of-undertakings] })
expect(response_subscriber_list[:id]).to eq(subscriber_list_tags_only.id)
end
end
Expand Down
14 changes: 7 additions & 7 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" => {
"any" => ["oil-and-gas/licensing"],
"tribunal_decision_categories" => {
"any" => %w[transfer-of-undertakings],
},
"location" => {
"all" => %w[france germany],
},
},
"links" => {
"topics" => {
"organisations" => {
"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: { organisations: %w[uuid-888] },
)

expect(response_subscriber_list).to include(
Expand All @@ -54,7 +54,7 @@
},
},
"links" => {
"topics" => {
"organisations" => {
"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: %w[transfer-of-undertakings] },
location: { all: %w[france germany] },
},
links: {
topics: { any: %w[uuid-888] },
organisations: { 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: %w[transfer-of-undertakings],
},
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
4 changes: 2 additions & 2 deletions 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":["agency-workers"]}},' \
'"links":{},"email_document_supertype":"","government_document_supertype":""}'

expected = CSV.generate do |csv|
Expand Down Expand Up @@ -68,7 +68,7 @@
it "can filter based on list tags (as a string)" do
create(:subscriber_list, tags: {})

output = described_class.new(created_at.to_s, tags_pattern: "road").call
output = described_class.new(created_at.to_s, tags_pattern: "agency").call
expect(output.lines.count).to eq 2

output = described_class.new(created_at.to_s, tags_pattern: "nothing").call
Expand Down
26 changes: 13 additions & 13 deletions spec/models/subscriber_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,58 @@
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[pension] } }

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[pension] } }

expect(subject).to be_valid
end

it "is invalid when tags 'hash' has values that are not whitelisted" do
subject.tags = {
foo: { any: %w[bar] },
foo: { any: %w[pension] },
dogs: { all: %w[bark] },
organisations: { any: %w[bar] },
people: { any: %w[bar] },
world_locations: { all: %w[bar] },
organisations: { any: %w[pension] },
people: { any: %w[pension] },
world_locations: { all: %w[pension] },
}

expect(subject).to be_invalid
expect(subject.errors[:tags]).to include("foo, dogs, organisations, people, and world_locations are not valid tags.")
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: "pension" } }

expect(subject).to be_invalid
expect(subject.errors[:tags]).to include("All tag values must be sent as Arrays")
end

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

expect(subject).to be_valid
end

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

expect(subject).to be_valid
end

it "is invalid when links 'hash' has 'any' values that are not arrays" do
subject.links = { foo: { any: "bar" } }
subject.links = { foo: { any: "pension" } }

expect(subject).to be_invalid
expect(subject.errors[:links]).to include("All link values must be sent as Arrays")
end

it "is invalid when links 'hash' has 'all' values that are not arrays" do
subject.links = { foo: { all: "bar" } }
subject.links = { foo: { all: "pension" } }

expect(subject).to be_invalid
expect(subject.errors[:links]).to include("All link 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: %w[pension], all: %w[transfer-of-undertakings] } })
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: %w[pension], all: %w[transfer-of-undertakings] })
end
end

Expand Down