diff --git a/lib/govuk_design_system_formbuilder/containers/supplemental.rb b/lib/govuk_design_system_formbuilder/containers/supplemental.rb index b890cd75..7b2c2e9b 100644 --- a/lib/govuk_design_system_formbuilder/containers/supplemental.rb +++ b/lib/govuk_design_system_formbuilder/containers/supplemental.rb @@ -10,6 +10,8 @@ def initialize(builder, object_name, attribute_name, content) def html return if @content.blank? + Rails.logger.warn("Supplemental content is deprecated and support will soon be removed. See https://github.com/x-govuk/govuk-form-builder/issues/445") + tag.div(id: supplemental_id) { @content } end diff --git a/spec/support/shared/shared_block_examples.rb b/spec/support/shared/shared_block_examples.rb index 1aad68da..28852ad0 100644 --- a/spec/support/shared/shared_block_examples.rb +++ b/spec/support/shared/shared_block_examples.rb @@ -25,6 +25,15 @@ with_tag('p', text: block_p) end end + + describe "deprecation warning message" do + before { allow(Rails).to receive_message_chain(:logger, :warn).with(any_args).and_return(true) } + + specify 'logs a deprecation warning' do + subject + expect(Rails.logger).to have_received(:warn).with(/Supplemental content is deprecated/) + end + end end context 'when no block is supplied' do