Skip to content

Commit

Permalink
Fix specs other than Pact specs
Browse files Browse the repository at this point in the history
  • Loading branch information
unoduetre committed Mar 13, 2024
1 parent 8e71410 commit 7189d1f
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 113 deletions.
36 changes: 18 additions & 18 deletions spec/commands/v2/patch_link_set_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
RSpec.describe Commands::V2::PatchLinkSet do
let(:expected_content_store_payload) { { base_path: "/vat-rates" } }
let(:content_id) { SecureRandom.uuid }
let(:topics) { 3.times.map { SecureRandom.uuid } }
let(:topics_shuffled) { topics.shuffle }
let(:taxons) { 3.times.map { SecureRandom.uuid } }
let(:taxons_shuffled) { taxons.shuffle }
let(:parent) { [SecureRandom.uuid] }

let(:payload) do
{
content_id:,
links: {
topics: topics * 2, # test deduplication
taxons: taxons * 2, # test deduplication
parent:,
},
}
Expand All @@ -20,7 +20,7 @@
{
content_id:,
links: {
topics: topics_shuffled * 2, # test deduplication
taxons: taxons_shuffled * 2, # test deduplication
parent:,
},
}
Expand Down Expand Up @@ -51,8 +51,8 @@
expect(link_set.content_id).to eq(content_id)

links = link_set.links
expect(links.map(&:link_type)).to eq(%w[parent topics topics topics])
expect(links.map(&:target_content_id)).to eq(parent + topics)
expect(links.map(&:link_type)).to eq(%w[parent taxons taxons taxons])
expect(links.map(&:target_content_id)).to eq(parent + taxons)
end

it "doesn't reject an empty links hash, but doesn't delete links either" do
Expand Down Expand Up @@ -89,7 +89,7 @@
content_id:,
version: 1,
links: {
topics:,
taxons:,
parent:,
},
)
Expand All @@ -103,8 +103,8 @@
expect(link_set.content_id).to eq(content_id)

links = link_set.links
expect(links.map(&:link_type)).to eq(%w[parent topics topics topics])
expect(links.map(&:target_content_id)).to eq(parent + topics_shuffled)
expect(links.map(&:link_type)).to eq(%w[parent taxons taxons taxons])
expect(links.map(&:target_content_id)).to eq(parent + taxons_shuffled)
end
end

Expand All @@ -119,13 +119,13 @@
links: [
create(
:link,
link_type: "topics",
target_content_id: topics.first,
link_type: "taxons",
target_content_id: taxons.first,
),
create(
:link,
link_type: "topics",
target_content_id: topics.second,
link_type: "taxons",
target_content_id: taxons.second,
),
create(
:link,
Expand Down Expand Up @@ -154,8 +154,8 @@
link_set = LinkSet.last
links = link_set.links

topics_links = links.where(link_type: "topics")
expect(topics_links.map(&:target_content_id)).to eq(topics)
taxons_links = links.where(link_type: "taxons")
expect(taxons_links.map(&:target_content_id)).to eq(taxons)
end

it "does not affect links for groups that do not appear in the payload" do
Expand Down Expand Up @@ -184,7 +184,7 @@
content_id:,
version: 2,
links: {
topics:,
taxons:,
parent:,
related:,
},
Expand Down Expand Up @@ -408,14 +408,14 @@
let(:content_id) { edition.document.content_id }

let(:payload) do
{ content_id:, links: { topics: [link_b] } }
{ content_id:, links: { taxons: [link_b] } }
end

before do
create(
:link_set,
content_id:,
links_hash: { topics: [link_a] },
links_hash: { taxons: [link_a] },
)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/commands/v2/publish_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -529,15 +529,15 @@
create(
:live_edition,
document:,
links_hash: { topics: [link_a] },
links_hash: { taxons: [link_a] },
)
end

let!(:draft_item) do
create(
:draft_edition,
document:,
links_hash: { topics: [link_b] },
links_hash: { taxons: [link_b] },
user_facing_version: 2,
)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/commands/v2/unpublish_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,15 @@
:draft_edition,
document:,
user_facing_version: 2,
links_hash: { topics: [link_b] },
links_hash: { taxons: [link_b] },
)
end

let!(:live_edition) do
create(
:live_edition,
document:,
links_hash: { topics: [link_a] },
links_hash: { taxons: [link_a] },
)
end

Expand Down
30 changes: 15 additions & 15 deletions spec/controllers/v2/content_items_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
:draft_edition,
document: document_en,
base_path: "/content.en",
document_type: "topic",
schema_name: "topic",
document_type: "taxon",
schema_name: "taxon",
user_facing_version: 2,
)
end
Expand All @@ -31,24 +31,24 @@
:draft_edition,
document: document_ar,
base_path: "/content.ar",
document_type: "topic",
schema_name: "topic",
document_type: "taxon",
schema_name: "taxon",
user_facing_version: 2,
)
@en_live_content = create(
:live_edition,
document: document_en,
base_path: "/content.en",
document_type: "guide",
schema_name: "topic",
schema_name: "taxon",
user_facing_version: 1,
)
@ar_live_content = create(
:live_edition,
document: document_ar,
base_path: "/content.ar",
document_type: "topic",
schema_name: "topic",
document_type: "taxon",
schema_name: "taxon",
user_facing_version: 1,
)
end
Expand All @@ -58,8 +58,8 @@
create(
:superseded_edition,
base_path: "/foo",
document_type: "topic",
schema_name: "topic",
document_type: "taxon",
schema_name: "taxon",
title: "zip",
user_facing_version: 1,
)
Expand All @@ -69,8 +69,8 @@
:live_edition,
base_path: "/foo",
document: previous_live_version.document,
document_type: "topic",
schema_name: "topic",
document_type: "taxon",
schema_name: "taxon",
title: "bar",
description: "stuff",
user_facing_version: 2,
Expand Down Expand Up @@ -179,7 +179,7 @@

context "with pagination params" do
before do
get :index, params: { content_format: "topic", fields: %w[content_id], start: "0", page_size: "20" }
get :index, params: { content_format: "taxon", fields: %w[content_id], start: "0", page_size: "20" }
end

it "is successful" do
Expand All @@ -193,7 +193,7 @@

context "without pagination params" do
before do
get :index, params: { content_format: "topic", fields: %w[content_id] }
get :index, params: { content_format: "taxon", fields: %w[content_id] }
end
it "is successful" do
expect(response.status).to eq(200)
Expand Down Expand Up @@ -349,7 +349,7 @@
link_set = create(:link_set, content_id:)
create(:link, link_set:, target_content_id: org_content_id)

get :index, params: { content_format: "topic", fields: %w[content_id], link_organisations: org_content_id.to_s }
get :index, params: { content_format: "taxon", fields: %w[content_id], link_organisations: org_content_id.to_s }
end

it "is successful" do
Expand Down Expand Up @@ -384,7 +384,7 @@
:draft_edition,
document: document_ar,
base_path: "/content.ar",
schema_name: "topic",
schema_name: "taxon",
user_facing_version: 2,
)

Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/v2/link_sets_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
describe "get_linked" do
context "called without providing fields parameter" do
it "is unsuccessful" do
get :get_linked, params: { content_id:, link_type: "topic" }
get :get_linked, params: { content_id:, link_type: "taxon" }
expect(response.status).to eq(422)
end
end

context "called with empty fields parameter" do
it "is unsuccessful" do
get :get_linked, params: { content_id:, link_type: "topic", fields: [] }
get :get_linked, params: { content_id:, link_type: "taxon", fields: [] }

expect(response.status).to eq(422)
end
Expand All @@ -67,7 +67,7 @@

context "for an existing edition" do
before do
get :get_linked, params: { content_id:, link_type: "topic", fields: %w[content_id] }
get :get_linked, params: { content_id:, link_type: "taxon", fields: %w[content_id] }
end

it "is successful" do
Expand All @@ -77,7 +77,7 @@

context "for a non-existing edition" do
before do
get :get_linked, params: { content_id: SecureRandom.uuid, link_type: "topic", fields: %w[content_id] }
get :get_linked, params: { content_id: SecureRandom.uuid, link_type: "taxon", fields: %w[content_id] }
end

it "is unsuccessful" do
Expand Down
Loading

0 comments on commit 7189d1f

Please sign in to comment.