Skip to content

Commit

Permalink
Add editor_id to top-level fields
Browse files Browse the repository at this point in the history
This ensures this value gets set if it is present. I’ve added some
shared exampes to the new edition and previous draft integration specs,
as these seemed like the best places for them to go.
  • Loading branch information
pezholio committed Oct 17, 2024
1 parent c7149f8 commit c0b892d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/edition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Edition < ApplicationRecord
description
details
document_type
editor_id
first_published_at
last_edited_at
major_published_at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
expect(previously_drafted_item.last_edited_at).to eq(Time.zone.now)
end

include_examples "setting editor_id" do
subject { previously_drafted_item.reload }
end

context "when public_updated_at is in the payload" do
let(:public_updated_at) { Time.zone.now }
before do
Expand Down
2 changes: 2 additions & 0 deletions spec/integration/put_content/new_edition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
include_examples "creates a change note"
end

include_examples "setting editor_id"

context "and the change history is in the details hash" do
before do
payload.delete(:change_note)
Expand Down
23 changes: 23 additions & 0 deletions spec/support/shared_context/put_content_calls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,27 @@
let(:locale) { "en" }
let(:content_id) { SecureRandom.uuid }
let(:change_note) { "change note" }

shared_examples "setting editor_id" do
context "when editor_id is present in the payload" do
let(:editor_id) { SecureRandom.uuid }
before do
payload.merge!(
editor_id:,
)
end

it "adds an editor_id to the edition" do
put "/v2/content/#{content_id}", params: payload.to_json

expect(subject.editor_id).to eq(editor_id)
end
end

it "does not set an editor_id by default" do
put "/v2/content/#{content_id}", params: payload.to_json

expect(subject.editor_id).to be_nil
end
end
end

0 comments on commit c0b892d

Please sign in to comment.