Skip to content

Commit

Permalink
Update pact test to reflect that Publishing API publish endpoint is n…
Browse files Browse the repository at this point in the history
…ow idempotent

The Publishing API publish endpoint used to return HTTP 409 Conflict error responses if a publishing app attempted to publish a content item which already had a published edition and no draft edition.

These errors are rarely very useful to the Publishing apps as they are usually caused by a duplicate request due to dependency resolution behaviour or Sidekiq's "at least once" guarantee.

We therefore updated Publishing API to return a 200 OK HTTP response is such cases, as the system is still in a perfectly valid state.
  • Loading branch information
ryanb-gds committed Jan 2, 2025
1 parent e0691d4 commit 4793d51
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions test/pacts/publishing_api/publish_pact_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
end
end

it "responds with 409 if the content item is already published" do
it "responds with 200 if the content item is already published" do
publishing_api
.given("a published content item exists with content_id: #{content_id}")
.upon_receiving("a publish request")
Expand All @@ -90,17 +90,10 @@
headers: GdsApi::JsonClient.default_request_with_json_body_headers,
)
.will_respond_with(
status: 409,
body: {
"error" => {
"code" => 409, "message" => Pact.term(generate: "Cannot publish an already published content item", matcher: /\S+/)
},
},
status: 200,
)

assert_raises(GdsApi::HTTPConflict) do
api_client.publish(content_id, "major")
end
api_client.publish(content_id, "major")
end

it "responds with 200 if the update information contains a locale" do
Expand Down

0 comments on commit 4793d51

Please sign in to comment.