Skip to content

Commit

Permalink
add content block postal fields to expansion rules
Browse files Browse the repository at this point in the history
the `content_block_postal_address` type is a placeholder
prototype to test blocks with more than one field. So I have
created a new type here that can be easily delete/merged
with a broader content block type if more are created.
  • Loading branch information
Harriethw committed Feb 3, 2025
1 parent 9dd458d commit 0731c0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/expansion_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def details_fields(*fields)

DEFAULT_FIELDS_AND_DESCRIPTION = (DEFAULT_FIELDS + [:description]).freeze

CONTENT_BLOCK_FIELDS = (DEFAULT_FIELDS + details_fields(:email_address)).freeze
CONTENT_BLOCK_EMAIL_FIELDS = (DEFAULT_FIELDS + details_fields(:email_address)).freeze
CONTENT_BLOCK_POSTAL_FIELDS = (DEFAULT_FIELDS + details_fields(:line_1, :town_or_city, :postcode)).freeze
CONTACT_FIELDS = (DEFAULT_FIELDS + details_fields(:description, :title, :contact_form_links, :post_addresses, :email_addresses, :phone_numbers)).freeze
GOVERNMENT_FIELDS = (MANDATORY_FIELDS + %i[api_path base_path document_type] + details_fields(:started_on, :ended_on, :current)).freeze
ORGANISATION_FIELDS = (DEFAULT_FIELDS - [:public_updated_at] + details_fields(:acronym, :logo, :brand, :default_news_image, :organisation_govuk_status)).freeze
Expand Down Expand Up @@ -164,7 +165,9 @@ def details_fields(*fields)
{ document_type: :contact,
fields: CONTACT_FIELDS },
{ document_type: :content_block_email_address,
fields: CONTENT_BLOCK_FIELDS },
fields: CONTENT_BLOCK_EMAIL_FIELDS },
{ document_type: :content_block_postal_address,
fields: CONTENT_BLOCK_POSTAL_FIELDS },
{ document_type: :topical_event,
fields: DEFAULT_FIELDS },
{ document_type: :organisation,
Expand Down
6 changes: 4 additions & 2 deletions spec/lib/expansion_rules_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
describe ".expansion_fields" do
let(:default_fields) { rules::DEFAULT_FIELDS }
let(:contact_fields) { default_fields + [%i[details description], %i[details title], %i[details contact_form_links], %i[details post_addresses], %i[details email_addresses], %i[details phone_numbers]] }
let(:content_block_fields) { default_fields + [%i[details email_address]] }
let(:content_block_email_fields) { default_fields + [%i[details email_address]] }
let(:content_block_postal_fields) { default_fields + [%i[details email_address]] }
let(:organisation_fields) { default_fields - [:public_updated_at] + [%i[details acronym], %i[details logo], %i[details brand], %i[details default_news_image], %i[details organisation_govuk_status]] }
let(:taxon_fields) { default_fields + %i[description details phase] }
let(:default_fields_and_description) { default_fields + %i[description] }
Expand Down Expand Up @@ -68,7 +69,8 @@
specify { expect(rules.expansion_fields(:parent)).to eq(default_fields) }

specify { expect(rules.expansion_fields(:contact)).to eq(contact_fields) }
specify { expect(rules.expansion_fields(:content_block_email_address)).to eq(content_block_fields) }
specify { expect(rules.expansion_fields(:content_block_email_address)).to eq(content_block_email_fields) }
specify { expect(rules.expansion_fields(:content_block_postal_address)).to eq(content_block_postal_fields) }
specify { expect(rules.expansion_fields(:historic_appointment)).to eq(historic_appointment_fields) }
specify { expect(rules.expansion_fields(:fatality_notice)).to eq(fatality_notice_fields) }
specify { expect(rules.expansion_fields(:mainstream_browse_page)).to eq(default_fields_and_description) }
Expand Down

0 comments on commit 0731c0e

Please sign in to comment.