Skip to content

Commit

Permalink
Merge pull request #71 from alphagov/string-payload
Browse files Browse the repository at this point in the history
Coerce documents' `payload_version` to int
  • Loading branch information
csutter authored Oct 27, 2023
2 parents 822d912 + 60efcc6 commit 004c786
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/document_sync_worker/document/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def content_id

# The payload version of the document.
def payload_version
document_hash.fetch("payload_version")
document_hash.fetch("payload_version").to_i
end

private
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/document_sync_worker/document/publish_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
end

let(:content_id) { "123" }
let(:payload_version) { 1 }
let(:payload_version) { "1" }
let(:document_type) { "press_release" }
let(:document_hash) do
{
Expand All @@ -24,7 +24,7 @@

describe "#payload_version" do
it "returns the payload_version from the document hash" do
expect(document.payload_version).to eq(payload_version)
expect(document.payload_version).to eq(1)
end
end

Expand Down Expand Up @@ -522,7 +522,7 @@
document.synchronize_to(repository)

expect(repository).to have_received(:put).with(
content_id, document.metadata, content: document.content, payload_version:
content_id, document.metadata, content: document.content, payload_version: 1
)
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/document_sync_worker/document/unpublish_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
end

let(:content_id) { "123" }
let(:payload_version) { 1 }
let(:payload_version) { "1" }
let(:document_type) { "gone" }
let(:document_hash) do
{
Expand All @@ -24,15 +24,15 @@

describe "#payload_version" do
it "returns the payload_version from the document hash" do
expect(document.payload_version).to eq(payload_version)
expect(document.payload_version).to eq(1)
end
end

describe "#synchronize_to" do
it "deletes the document from the repository" do
document.synchronize_to(repository)

expect(repository).to have_received(:delete).with(content_id, payload_version:)
expect(repository).to have_received(:delete).with(content_id, payload_version: 1)
end
end
end

0 comments on commit 004c786

Please sign in to comment.