diff --git a/guide/lib/helpers.rb b/guide/lib/helpers.rb index 6b59b4cb..57c8b103 100644 --- a/guide/lib/helpers.rb +++ b/guide/lib/helpers.rb @@ -1,10 +1,13 @@ require 'pry' +require 'rails' require 'action_view' require 'active_model' require 'active_support/core_ext/string' require 'htmlbeautifier' require 'slim/erb_converter' +Rails.logger = Logger.new($stdout) + Dir.glob(File.join('./lib', '**', '*.rb')).sort.each { |f| require f } $LOAD_PATH.unshift(File.expand_path("../../lib", "lib")) diff --git a/lib/govuk_design_system_formbuilder/containers/supplemental.rb b/lib/govuk_design_system_formbuilder/containers/supplemental.rb index b890cd75..bc5ba524 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? + 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