Browse Source

Display input playback on the page

pull/2374/head
Kat 2 years ago
parent
commit
8c3db71b22
  1. 2
      app/models/form/question.rb
  2. 4
      app/views/form/_radio_question.html.erb
  3. 17
      spec/views/form/page_view_spec.rb

2
app/models/form/question.rb

@ -60,6 +60,8 @@ class Form::Question
def notification_banner(_log = nil); end def notification_banner(_log = nil); end
def input_playback(_log = nil); end
def get_inferred_answers(log) def get_inferred_answers(log)
return [] unless inferred_answers return [] unless inferred_answers

4
app/views/form/_radio_question.html.erb

@ -8,6 +8,10 @@
simple_format(banner[:heading]) simple_format(banner[:heading])
end %> end %>
<% end %> <% end %>
<% input_playback = question.input_playback(@log) %>
<% if input_playback %>
<p class="govuk-body"><%= input_playback %></p>
<% end %>
<%= f.govuk_radio_buttons_fieldset question.id.to_sym, <%= f.govuk_radio_buttons_fieldset question.id.to_sym,
caption: caption(caption_text, page_header, conditional), caption: caption(caption_text, page_header, conditional),

17
spec/views/form/page_view_spec.rb

@ -150,4 +150,21 @@ RSpec.describe "form/page" do
end end
end 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 end

Loading…
Cancel
Save