Browse Source

Remove some of the previous soft validations set up

pull/338/head
Kat 3 years ago committed by MadeTech Dushan
parent
commit
3dd15cda61
  1. 9
      app/models/form/page.rb
  2. 15
      app/views/form/_validation_override_question.html.erb
  3. 4
      app/views/form/page.html.erb
  4. 1
      config/routes.rb
  5. 4
      spec/fixtures/complete_case_log.json
  6. 2
      spec/fixtures/forms/2021_2022.json
  7. 3
      spec/helpers/check_answers_helper_spec.rb
  8. 9
      spec/models/form/page_spec.rb

9
app/models/form/page.rb

@ -1,5 +1,5 @@
class Form::Page
attr_accessor :id, :header, :description, :questions, :soft_validations,
attr_accessor :id, :header, :description, :questions,
:depends_on, :title_text, :informative_text, :subsection, :hide_subsection_label
def initialize(id, hsh, subsection)
@ -11,16 +11,11 @@ class Form::Page
@title_text = hsh["title_text"]
@informative_text = hsh["informative_text"]
@hide_subsection_label = hsh["hide_subsection_label"]
@soft_validations = hsh["soft_validations"]&.map { |sv_id, s| Form::Question.new(sv_id, s, self) }
@subsection = subsection
end
def expected_responses
questions + (soft_validations || [])
end
def has_soft_validations?
soft_validations.present?
questions
end
def routed_to?(case_log)

15
app/views/form/_validation_override_question.html.erb

@ -1,15 +0,0 @@
<div class="govuk-form-group govuk-form-group--error"
data-controller="soft-validations"
data-soft-validations-target="override"
style='display:none;'>
<%= f.govuk_check_boxes_fieldset page.soft_validations&.first&.id.to_sym,
legend: { text: "soft-validations-placeholder-message", size: "l" },
hint: { text: "soft-validations-placeholder-hint-text" } do %>
<%= f.govuk_check_box page.soft_validations&.first&.id, page.soft_validations&.first&.id,
label: { text: "Yes" },
checked: @case_log[page.soft_validations&.first&.id] == "Yes"
%>
<% end %>
</div>

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

@ -46,10 +46,6 @@
</div>
<% end %>
<% if @page.has_soft_validations? %>
<%= render partial: "form/validation_override_question", locals: { f: f, page: @page } %>
<% end %>
<%= f.hidden_field :page, value: @page.id %>
<% if @case_log.form.is_last_question?(@page, @subsection, @case_log) %>
<%= f.govuk_submit "Submit lettings log", accesskey: "s" %>

1
config/routes.rb

@ -60,7 +60,6 @@ Rails.application.routes.draw do
FormHandler.instance.forms.each do |_key, form|
form.pages.map do |page|
get page.id.to_s.dasherize, to: "form##{page.id}"
get "#{page.id.to_s.dasherize}/soft-validations", to: "soft_validations#show" if page.has_soft_validations?
end
form.subsections.map do |subsection|

4
spec/fixtures/complete_case_log.json vendored

@ -118,7 +118,7 @@
"rp_hardship": 0,
"rp_dontknow": 0,
"discarded_at": "05/05/2020",
"net_income_value_check": "",
"net_income_value_check": 0,
"property_owner_organisation": "",
"property_manager_organisation": "",
"rent_type": 0,
@ -141,7 +141,7 @@
"has_benefits": 1,
"household_charge": 1,
"is_carehome": 1,
"chcharge": 6,
"chcharge": 6,
"letting_in_sheltered_accommodation": 0,
"declaration": 1,
"referral": 1

2
spec/fixtures/forms/2021_2022.json vendored

@ -70,7 +70,7 @@
"questions": {
"ecstat1": {
"check_answer_label": "Lead tenant’s working situation",
"header": "Which of these best describes the lead tenant’s working situation?",
"header": "Which of these best describes the lead tenant’s socks?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
"type": "radio",
"answer_options": {

3
spec/helpers/check_answers_helper_spec.rb

@ -9,7 +9,7 @@ RSpec.describe CheckAnswersHelper do
context "when a section hasn't been completed yet" do
it "returns that you have unanswered questions" do
expect(display_answered_questions_summary(subsection, case_log))
.to match(/You have answered 2 of 5 questions./)
.to match(/You have answered 2 of 6 questions./)
end
end
@ -18,6 +18,7 @@ RSpec.describe CheckAnswersHelper do
case_log.sex1 = "F"
case_log.other_hhmemb = 0
case_log.propcode = "123"
case_log.ecstat1 = 200
expect(display_answered_questions_summary(subsection, case_log))
.to match(/You answered all the questions./)
expect(display_answered_questions_summary(subsection, case_log))

9
spec/models/form/page_spec.rb

@ -31,15 +31,6 @@ RSpec.describe Form::Page, type: :model do
expect(page.questions.map(&:id)).to eq(expected_questions)
end
it "has soft validations" do
expected_soft_validations = %w[net_income_value_check]
expect(page.soft_validations.map(&:id)).to eq(expected_soft_validations)
end
it "has a soft_validation helper" do
expect(page.has_soft_validations?).to be true
end
it "has expected form responses" do
expected_responses = %w[earnings incfreq net_income_value_check]
expect(page.expected_responses.map(&:id)).to eq(expected_responses)

Loading…
Cancel
Save