diff --git a/app/models/form/question.rb b/app/models/form/question.rb index 0c1611e60..752726fb1 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -60,6 +60,8 @@ class Form::Question def notification_banner(_log = nil); end + def input_playback(_log = nil); end + def get_inferred_answers(log) return [] unless inferred_answers diff --git a/app/views/form/_radio_question.html.erb b/app/views/form/_radio_question.html.erb index d126b89d8..c15b31b58 100644 --- a/app/views/form/_radio_question.html.erb +++ b/app/views/form/_radio_question.html.erb @@ -8,6 +8,10 @@ simple_format(banner[:heading]) end %> <% end %> + <% input_playback = question.input_playback(@log) %> + <% if input_playback %> +

<%= input_playback %>

+ <% end %> <%= f.govuk_radio_buttons_fieldset question.id.to_sym, caption: caption(caption_text, page_header, conditional), diff --git a/spec/views/form/page_view_spec.rb b/spec/views/form/page_view_spec.rb index 6664981f9..16c4c0672 100644 --- a/spec/views/form/page_view_spec.rb +++ b/spec/views/form/page_view_spec.rb @@ -150,4 +150,21 @@ RSpec.describe "form/page" do end end end + + context "with a question containing input playback" do + let(:expected_playback) { /This is input playback/ } + + context "with radio type" do + let(:question_attributes) { { type: "radio", answer_options: { "1": "A", "2": "B" } } } + + before do + allow(question).to receive(:input_playback).and_return("This is input playback") + render + end + + it "renders the input playback for radio questions" do + expect(rendered).to match(expected_playback) + end + end + end end