Browse Source

Set grey background if the field is readonly (#234)

* Set grey background if the field is readonly

* fix tests
pull/237/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
1fb7b09c0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/helpers/question_attribute_helper.rb
  2. 17
      spec/fixtures/forms/2021_2022.json
  3. 2
      spec/helpers/question_attribute_helper_spec.rb
  4. 2
      spec/models/form_handler_spec.rb

1
app/helpers/question_attribute_helper.rb

@ -10,6 +10,7 @@ module QuestionAttributeHelper
private
def numeric_question_html_attributes(question)
return { "style": "background-color: #f3f2f1;" } if question.read_only?
return {} if question.fields_to_add.blank? || question.result_field.blank?
{

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

@ -541,6 +541,23 @@
"requires_js": true
}
}
},
"weekly_net_income": {
"header": "",
"description": "",
"questions": {
"earnings": {
"check_answer_label": "Total household income",
"header": "How much income does the household have in total every week?",
"hint_text": "",
"type": "numeric",
"min": 0,
"step": "1",
"width": 5,
"prefix": "£",
"suffix": " every week"
}
}
}
}
}

2
spec/helpers/question_attribute_helper_spec.rb

@ -7,7 +7,7 @@ RSpec.describe QuestionAttributeHelper do
describe "html attributes" do
it "returns empty hash if fields-to-add or result-field are empty " do
question = questions.find { |q| q.id == "tcharge" }
question = form.get_page("weekly_net_income").questions.find { |q| q.id == "earnings" }
expect(stimulus_html_attributes(question)).to eq({})
end

2
spec/models/form_handler_spec.rb

@ -16,7 +16,7 @@ RSpec.describe FormHandler do
form_handler = FormHandler.instance
form = form_handler.get_form(test_form_name)
expect(form).to be_a(Form)
expect(form.pages.count).to eq(28)
expect(form.pages.count).to eq(29)
end
end

Loading…
Cancel
Save