Skip to content

Commit

Permalink
Remove specialist topics code
Browse files Browse the repository at this point in the history
In publishing api pact tests.
Replace topic with taxon.
Update CHANGELOG.md
  • Loading branch information
unoduetre committed Mar 27, 2024
1 parent d1809c4 commit 835158d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 41 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
# Unreleased
* Update Pact specs to match the publishing-api [PR](https://github.com/alphagov/publishing-api/pull/2669)

# 95.0.0

* BREAKING: Drop 'named contact' API methods from Support app.
Expand Down
40 changes: 20 additions & 20 deletions test/pacts/publishing_api/get_content_items_pact_test.rb
Expand Up @@ -9,12 +9,12 @@

it "returns the content items of a certain document_type" do
publishing_api
.given("there is content with document_type 'topic'")
.given("there is content with document_type 'taxon'")
.upon_receiving("a get entries request")
.with(
method: :get,
path: "/v2/content",
query: "document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path",
query: "document_type=taxon&fields%5B%5D=title&fields%5B%5D=base_path",
)
.will_respond_with(
status: 200,
Expand All @@ -23,7 +23,7 @@
pages: 1,
current_page: 1,
links: [{
href: "http://example.org/v2/content?document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path&page=1",
href: "http://example.org/v2/content?document_type=taxon&fields%5B%5D=title&fields%5B%5D=base_path&page=1",
rel: "self",
}],
results: [
Expand All @@ -34,7 +34,7 @@
)

api_client.get_content_items(
document_type: "topic",
document_type: "taxon",
fields: %i[title base_path],
)
end
Expand All @@ -46,7 +46,7 @@
.with(
method: :get,
path: "/v2/content",
query: "document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale",
query: "document_type=taxon&fields%5B%5D=content_id&fields%5B%5D=locale",
)
.will_respond_with(
status: 200,
Expand All @@ -55,7 +55,7 @@
pages: 1,
current_page: 1,
links: [{
href: "http://example.org/v2/content?document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale&page=1",
href: "http://example.org/v2/content?document_type=taxon&fields%5B%5D=content_id&fields%5B%5D=locale&page=1",
rel: "self",
}],
results: [
Expand All @@ -65,7 +65,7 @@
)

api_client.get_content_items(
document_type: "topic",
document_type: "taxon",
fields: %i[content_id locale],
)
end
Expand All @@ -77,7 +77,7 @@
.with(
method: :get,
path: "/v2/content",
query: "document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale&locale=fr",
query: "document_type=taxon&fields%5B%5D=content_id&fields%5B%5D=locale&locale=fr",
)
.will_respond_with(
status: 200,
Expand All @@ -86,7 +86,7 @@
pages: 1,
current_page: 1,
links: [{
href: "http://example.org/v2/content?document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale&locale=fr&page=1",
href: "http://example.org/v2/content?document_type=taxon&fields%5B%5D=content_id&fields%5B%5D=locale&locale=fr&page=1",
rel: "self",
}],
results: [
Expand All @@ -96,7 +96,7 @@
)

api_client.get_content_items(
document_type: "topic",
document_type: "taxon",
fields: %i[content_id locale],
locale: "fr",
)
Expand All @@ -109,7 +109,7 @@
.with(
method: :get,
path: "/v2/content",
query: "document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale&locale=all",
query: "document_type=taxon&fields%5B%5D=content_id&fields%5B%5D=locale&locale=all",
)
.will_respond_with(
status: 200,
Expand All @@ -118,7 +118,7 @@
pages: 1,
current_page: 1,
links: [{
href: "http://example.org/v2/content?document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale&locale=all&page=1",
href: "http://example.org/v2/content?document_type=taxon&fields%5B%5D=content_id&fields%5B%5D=locale&locale=all&page=1",
rel: "self",
}],
results: [
Expand All @@ -130,7 +130,7 @@
)

api_client.get_content_items(
document_type: "topic",
document_type: "taxon",
fields: %i[content_id locale],
locale: "all",
)
Expand All @@ -143,7 +143,7 @@
.with(
method: :get,
path: "/v2/content",
query: "document_type=topic&fields%5B%5D=content_id&fields%5B%5D=details",
query: "document_type=taxon&fields%5B%5D=content_id&fields%5B%5D=details",
)
.will_respond_with(
status: 200,
Expand All @@ -152,7 +152,7 @@
pages: 1,
current_page: 1,
links: [{
href: "http://example.org/v2/content?document_type=topic&fields%5B%5D=content_id&fields%5B%5D=details&page=1",
href: "http://example.org/v2/content?document_type=taxon&fields%5B%5D=content_id&fields%5B%5D=details&page=1",
rel: "self",
}],
results: [
Expand All @@ -162,19 +162,19 @@
)

api_client.get_content_items(
document_type: "topic",
document_type: "taxon",
fields: %i[content_id details],
)
end

it "returns the items matching a query" do
publishing_api
.given("there is content with document_type 'topic'")
.given("there is content with document_type 'taxon'")
.upon_receiving("a get entries request with search_in and q parameters")
.with(
method: :get,
path: "/v2/content",
query: "document_type=topic&fields%5B%5D=content_id&q=an+internal+name&search_in%5B%5D=details.internal_name",
query: "document_type=taxon&fields%5B%5D=content_id&q=an+internal+name&search_in%5B%5D=details.internal_name",
)
.will_respond_with(
status: 200,
Expand All @@ -183,7 +183,7 @@
pages: 1,
current_page: 1,
links: [{
href: "http://example.org/v2/content?document_type=topic&fields%5B%5D=content_id&q=an+internal+name&search_in%5B%5D=details.internal_name&page=1",
href: "http://example.org/v2/content?document_type=taxon&fields%5B%5D=content_id&q=an+internal+name&search_in%5B%5D=details.internal_name&page=1",
rel: "self",
}],
results: [
Expand All @@ -193,7 +193,7 @@
)

api_client.get_content_items(
document_type: "topic",
document_type: "taxon",
fields: [:content_id],
q: "an internal name",
search_in: ["details.internal_name"],
Expand Down
6 changes: 3 additions & 3 deletions test/pacts/publishing_api/get_linkables_pact_test.rb
Expand Up @@ -26,18 +26,18 @@

it "returns the content items of a given document_type" do
publishing_api
.given("there is content with document_type 'topic'")
.given("there is content with document_type 'taxon'")
.upon_receiving("a get linkables request")
.with(
method: :get,
path: "/v2/linkables",
query: "document_type=topic",
query: "document_type=taxon",
)
.will_respond_with(
status: 200,
body: linkables,
)

api_client.get_linkables(document_type: "topic")
api_client.get_linkables(document_type: "taxon")
end
end
10 changes: 5 additions & 5 deletions test/pacts/publishing_api/get_linked_items_pact_test.rb
Expand Up @@ -14,7 +14,7 @@
.with(
method: :get,
path: "/v2/linked/#{content_id}",
query: "fields%5B%5D=content_id&fields%5B%5D=base_path&link_type=topic",
query: "fields%5B%5D=content_id&fields%5B%5D=base_path&link_type=taxon",
)
.will_respond_with(
status: 404,
Expand All @@ -32,7 +32,7 @@
assert_raises(GdsApi::HTTPNotFound) do
api_client.get_linked_items(
content_id,
link_type: "topic",
link_type: "taxon",
fields: %w[content_id base_path],
)
end
Expand All @@ -57,12 +57,12 @@

before do
publishing_api
.given("there are two documents with a 'topic' link to another document")
.given("there are two documents with a 'taxon' link to another document")
.upon_receiving("a get linked request")
.with(
method: :get,
path: "/v2/linked/#{linked_content_id}",
query: "fields%5B%5D=content_id&fields%5B%5D=base_path&link_type=topic",
query: "fields%5B%5D=content_id&fields%5B%5D=base_path&link_type=taxon",
)
.will_respond_with(
status: 200,
Expand All @@ -82,7 +82,7 @@
it "returns the requested fields of linking items" do
response = api_client.get_linked_items(
linked_content_id,
link_type: "topic",
link_type: "taxon",
fields: %w[content_id base_path],
)
assert_equal 200, response.code
Expand Down
18 changes: 9 additions & 9 deletions test/pacts/publishing_api/get_paged_content_items_pact_test.rb
Expand Up @@ -8,22 +8,22 @@

it "returns two content items" do
publishing_api
.given("there are four content items with document_type 'topic'")
.given("there are four content items with document_type 'taxon'")
.upon_receiving("get the first page request")
.with(
method: :get,
path: "/v2/content",
query: "document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path&page=1&per_page=2",
query: "document_type=taxon&fields%5B%5D=title&fields%5B%5D=base_path&page=1&per_page=2",
)
.will_respond_with(
status: 200,
body: {
total: 4,
pages: 2,
current_page: 1,
links: [{ href: "http://example.org/v2/content?document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path&per_page=2&page=2",
links: [{ href: "http://example.org/v2/content?document_type=taxon&fields%5B%5D=title&fields%5B%5D=base_path&per_page=2&page=2",
rel: "next" },
{ href: "http://example.org/v2/content?document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path&per_page=2&page=1",
{ href: "http://example.org/v2/content?document_type=taxon&fields%5B%5D=title&fields%5B%5D=base_path&per_page=2&page=1",
rel: "self" }],
results: [
{ title: "title_1", base_path: "/path_1" },
Expand All @@ -32,22 +32,22 @@
},
)
publishing_api
.given("there are four content items with document_type 'topic'")
.given("there are four content items with document_type 'taxon'")
.upon_receiving("get the second page request")
.with(
method: :get,
path: "/v2/content",
query: "document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path&page=2&per_page=2",
query: "document_type=taxon&fields%5B%5D=title&fields%5B%5D=base_path&page=2&per_page=2",
)
.will_respond_with(
status: 200,
body: {
total: 4,
pages: 2,
current_page: 2,
links: [{ href: "http://example.org/v2/content?document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path&per_page=2&page=1",
links: [{ href: "http://example.org/v2/content?document_type=taxon&fields%5B%5D=title&fields%5B%5D=base_path&per_page=2&page=1",
rel: "previous" },
{ href: "http://example.org/v2/content?document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path&per_page=2&page=2",
{ href: "http://example.org/v2/content?document_type=taxon&fields%5B%5D=title&fields%5B%5D=base_path&per_page=2&page=2",
rel: "self" }],
results: [
{ title: "title_3", base_path: "/path_3" },
Expand All @@ -56,7 +56,7 @@
},
)
assert_equal(
api_client.get_content_items_enum(document_type: "topic", fields: %i[title base_path], per_page: 2).to_a,
api_client.get_content_items_enum(document_type: "taxon", fields: %i[title base_path], per_page: 2).to_a,
[
{ "title" => "title_1", "base_path" => "/path_1" },
{ "title" => "title_2", "base_path" => "/path_2" },
Expand Down
8 changes: 4 additions & 4 deletions test/pacts/publishing_api/patch_links_pact_test.rb
Expand Up @@ -43,13 +43,13 @@
it "adds the new type of links and responds with the whole link set when setting links of a different type" do
publishing_api
.given("organisation links exist for content_id #{content_id}")
.upon_receiving("a patch topic links request")
.upon_receiving("a patch taxons links request")
.with(
method: :patch,
path: "/v2/links/#{content_id}",
body: {
links: {
topics: %w[225df4a8-2945-4e9b-8799-df7424a90b69],
taxons: %w[225df4a8-2945-4e9b-8799-df7424a90b69],
},
},
headers: {
Expand All @@ -60,7 +60,7 @@
status: 200,
body: {
links: {
topics: %w[225df4a8-2945-4e9b-8799-df7424a90b69],
taxons: %w[225df4a8-2945-4e9b-8799-df7424a90b69],
organisations: %w[20583132-1619-4c68-af24-77583172c070],
},
},
Expand All @@ -69,7 +69,7 @@
api_client.patch_links(
content_id,
links: {
topics: %w[225df4a8-2945-4e9b-8799-df7424a90b69],
taxons: %w[225df4a8-2945-4e9b-8799-df7424a90b69],
},
)
end
Expand Down

0 comments on commit 835158d

Please sign in to comment.