Skip to content
This repository was archived by the owner on Oct 27, 2025. It is now read-only.

Commit a351f80

Browse files
committed
Add 'political' property to hash
Content Publisher has two means of designating an edition to be 'political': 1. 'system political': if associated with role appointments or political organisations 2. 'editor political': if the publisher has explicitly marked the document as political via the "Gets history mode" checkbox in Content Publisher's UI. For the purposes of importing these docs into Whitehall, we don't particularly care the _means_ by which a document is considered political. We don't need the overhead of having to map one 'flavour' of political to Whitehall's representation of that 'flavour'. It is enough to just pass the derived boolean from Content Publisher, into Whitehall (which has its own 'political' boolean override equivalent: https://github.com/alphagov/whitehall/blob/f5afce65514b02767df8625ccfa40c681046c95e/db/schema.rb#L444)
1 parent 7ede631 commit a351f80

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

app/models/whitehall_migration/document_export.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def self.export_to_hash(document)
2323
summary: content_revision.summary,
2424
body: content_revision.contents["body"],
2525
tags: document.live_edition.revision.tags_revision.tags,
26+
political: document.live_edition.political?,
2627
}
2728
end
2829
end

spec/models/whitehall_migration/document_export_spec.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,16 @@
102102
tags = { "primary_publishing_organisation" => [SecureRandom.uuid] }
103103
document = build(:document, :live)
104104
document.live_edition = create(:edition, :published, document:, tags:)
105-
105+
106106
expect(described_class.export_to_hash(document)[:tags]).to eq(tags)
107107
end
108+
109+
it "has a `political` property" do
110+
document = build(:document, :live)
111+
document.live_edition = create(:edition, :published, document:)
112+
allow(document.live_edition).to receive(:political?).and_return(true)
113+
114+
expect(described_class.export_to_hash(document)[:political]).to be(true)
115+
end
108116
end
109117
end

0 commit comments

Comments
 (0)