Browse Source

Radio options

pull/22/head
baarkerlounger 3 years ago
parent
commit
1b45800fbb
  1. 48
      app/views/form/questions/previous_housing_situation.html.erb
  2. 26
      app/views/form/questions/tenant_economic_status.html.erb
  3. 40
      app/views/form/questions/tenant_ethnic_group.html.erb
  4. 10
      app/views/form/questions/tenant_gender.html.erb
  5. 34
      app/views/form/questions/tenant_nationality.html.erb
  6. 8
      spec/features/case_log_spec.rb

48
app/views/form/questions/previous_housing_situation.html.erb

@ -1,27 +1,27 @@
<% situations = [ <% situations = [
OpenStruct.new(id: 0, name: "Owner occupation (private)"), OpenStruct.new(id: 0, value: "Owner occupation (private)"),
OpenStruct.new(id: 1, name: "Owner occupation (low cost home ownership)"), OpenStruct.new(id: 1, value: "Owner occupation (low cost home ownership)"),
OpenStruct.new(id: 2, name: "Private sector tenancy"), OpenStruct.new(id: 2, value: "Private sector tenancy"),
OpenStruct.new(id: 3, name: "Tied housing or rented with job"), OpenStruct.new(id: 3, value: "Tied housing or rented with job"),
OpenStruct.new(id: 4, name: "Supported housing"), OpenStruct.new(id: 4, value: "Supported housing"),
OpenStruct.new(id: 5, name: "Sheltered accomodation"), OpenStruct.new(id: 5, value: "Sheltered accomodation"),
OpenStruct.new(id: 6, name: "Residential care home"), OpenStruct.new(id: 6, value: "Residential care home"),
OpenStruct.new(id: 7, name: "Living with friends or family"), OpenStruct.new(id: 7, value: "Living with friends or family"),
OpenStruct.new(id: 8, name: "Refuge"), OpenStruct.new(id: 8, value: "Refuge"),
OpenStruct.new(id: 9, name: "Hospital"), OpenStruct.new(id: 9, value: "Hospital"),
OpenStruct.new(id: 10, name: "Prison / Approved Probation Hostel"), OpenStruct.new(id: 10, value: "Prison / Approved Probation Hostel"),
OpenStruct.new(id: 11, name: "Direct access hostel"), OpenStruct.new(id: 11, value: "Direct access hostel"),
OpenStruct.new(id: 12, name: "Bed & Breakfast"), OpenStruct.new(id: 12, value: "Bed & Breakfast"),
OpenStruct.new(id: 13, name: "Mobile home / caravan"), OpenStruct.new(id: 13, value: "Mobile home / caravan"),
OpenStruct.new(id: 14, name: "Any other temporary accommodation"), OpenStruct.new(id: 14, value: "Any other temporary accommodation"),
OpenStruct.new(id: 15, name: "Home Office Asylum Support"), OpenStruct.new(id: 15, value: "Home Office Asylum Support"),
OpenStruct.new(id: 16, name: "Children’s home / foster care"), OpenStruct.new(id: 16, value: "Children’s home / foster care"),
OpenStruct.new(id: 17, name: "Rough sleeping"), OpenStruct.new(id: 17, value: "Rough sleeping"),
OpenStruct.new(id: 18, name: "Other"), OpenStruct.new(id: 18, value: "Other"),
OpenStruct.new(id: 19, name: "Fixed term Local Authority General Needs tenancy"), OpenStruct.new(id: 19, value: "Fixed term Local Authority General Needs tenancy"),
OpenStruct.new(id: 20, name: "Lifetime Local Authority General Needs tenancy"), OpenStruct.new(id: 20, value: "Lifetime Local Authority General Needs tenancy"),
OpenStruct.new(id: 21, name: "Fixed term PRP General Needs tenancy"), OpenStruct.new(id: 21, value: "Fixed term PRP General Needs tenancy"),
OpenStruct.new(id: 22, name: "Lifetime PRP General Needs tenancy"), OpenStruct.new(id: 22, value: "Lifetime PRP General Needs tenancy"),
] %> ] %>
<% previous_question = Form.previous_question("previous_housing_situation") %> <% previous_question = Form.previous_question("previous_housing_situation") %>
@ -33,7 +33,7 @@
<%= turbo_frame_tag "case_log_form", target: "_top" do %> <%= turbo_frame_tag "case_log_form", target: "_top" do %>
<%= form_with action: '/case_logs', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> <%= form_with action: '/case_logs', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_collection_radio_buttons :previous_housing_situation, situations, :id, :name, legend: { text: "What was the tenant’s housing situation immediately before this letting?", size: "l" } %> <%= f.govuk_collection_radio_buttons :previous_housing_situation, situations, :id, :value, legend: { text: "What was the tenant’s housing situation immediately before this letting?", size: "l" } %>
<%= f.hidden_field :previous_question, value: :previous_housing_situation %> <%= f.hidden_field :previous_question, value: :previous_housing_situation %>
<%= f.hidden_field :case_log_id, value: case_log_id %> <%= f.hidden_field :case_log_id, value: case_log_id %>
<%= f.govuk_submit "Save and continue" %> <%= f.govuk_submit "Save and continue" %>

26
app/views/form/questions/tenant_economic_status.html.erb

@ -1,18 +1,18 @@
<% economic_statuses = [ <% economic_statuses = [
OpenStruct.new(id: 0, economic_status: "Part-time - Less than 30 hours"), OpenStruct.new(id: 0, value: "Part-time - Less than 30 hours"),
OpenStruct.new(id: 1, economic_status: "Full-time - 30 hours or more"), OpenStruct.new(id: 1, value: "Full-time - 30 hours or more"),
OpenStruct.new(id: 2, economic_status: "In government training into work, such as New Deal"), OpenStruct.new(id: 2, value: "In government training into work, such as New Deal"),
OpenStruct.new(id: 3, economic_status: "Jobseeker"), OpenStruct.new(id: 3, value: "Jobseeker"),
OpenStruct.new(id: 4, economic_status: "Retired"), OpenStruct.new(id: 4, value: "Retired"),
OpenStruct.new(id: 5, economic_status: "Not seeking work"), OpenStruct.new(id: 5, value: "Not seeking work"),
OpenStruct.new(id: 6, economic_status: "Full-time student"), OpenStruct.new(id: 6, value: "Full-time student"),
OpenStruct.new(id: 7, economic_status: "Unable to work because of long term sick or disability"), OpenStruct.new(id: 7, value: "Unable to work because of long term sick or disability"),
OpenStruct.new(id: 8, economic_status: "Child under 16"), OpenStruct.new(id: 8, value: "Child under 16"),
OpenStruct.new(id: 9, economic_status: "Other"), OpenStruct.new(id: 9, value: "Other"),
OpenStruct.new(id: 10, economic_status: "Prefer not to say") OpenStruct.new(id: 10, value: "Prefer not to say")
] %> ] %>
<% previous_question = Form.previous_question("tenant_economic_status") %> <% previous_question = Form.previous_question("tenant_value") %>
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link href: "/case_logs/#{case_log_id}/#{previous_question}" do %> <%= govuk_back_link href: "/case_logs/#{case_log_id}/#{previous_question}" do %>
Back Back
@ -21,7 +21,7 @@
<%= turbo_frame_tag "case_log_form", target: "_top" do %> <%= turbo_frame_tag "case_log_form", target: "_top" do %>
<%= form_with action: '/case_logs', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> <%= form_with action: '/case_logs', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_collection_radio_buttons :tenant_economic_status, economic_statuses, :id, legend: { text: "Which of these best describes the tenant's working situation?", size: "l" } %> <%= f.govuk_collection_radio_buttons :tenant_economic_status, economic_statuses, :id, :value, legend: { text: "Which of these best describes the tenant's working situation?", size: "l" } %>
<%= f.hidden_field :previous_question, value: :tenant_economic_status %> <%= f.hidden_field :previous_question, value: :tenant_economic_status %>
<%= f.hidden_field :case_log_id, value: case_log_id %> <%= f.hidden_field :case_log_id, value: case_log_id %>
<%= f.govuk_submit "Save and continue" %> <%= f.govuk_submit "Save and continue" %>

40
app/views/form/questions/tenant_ethnic_group.html.erb

@ -1,23 +1,23 @@
<% ethnic_groups = [ <% ethnic_groups = [
OpenStruct.new(id: 0, ethnicity: "White: English/Scottish/Welsh/Northern Irish/British"), OpenStruct.new(id: 0, value: "White: English/Scottish/Welsh/Northern Irish/British"),
OpenStruct.new(id: 1, ethnicity: "White: Irish"), OpenStruct.new(id: 1, value: "White: Irish"),
OpenStruct.new(id: 2, ethnicity: "White: Gypsy/Irish Traveller"), OpenStruct.new(id: 2, value: "White: Gypsy/Irish Traveller"),
OpenStruct.new(id: 3, ethnicity: "White: Other"), OpenStruct.new(id: 3, value: "White: Other"),
OpenStruct.new(id: 4, ethnicity: "Mixed: White & Black Caribbean"), OpenStruct.new(id: 4, value: "Mixed: White & Black Caribbean"),
OpenStruct.new(id: 5, ethnicity: "Mixed: White & Black African"), OpenStruct.new(id: 5, value: "Mixed: White & Black African"),
OpenStruct.new(id: 6, ethnicity: "Mixed: White & Asian"), OpenStruct.new(id: 6, value: "Mixed: White & Asian"),
OpenStruct.new(id: 7, ethnicity: "Mixed: Other"), OpenStruct.new(id: 7, value: "Mixed: Other"),
OpenStruct.new(id: 8, ethnicity: "Asian or Asian British: Indian"), OpenStruct.new(id: 8, value: "Asian or Asian British: Indian"),
OpenStruct.new(id: 9, ethnicity: "Asian or Asian British: Pakistani"), OpenStruct.new(id: 9, value: "Asian or Asian British: Pakistani"),
OpenStruct.new(id: 10, ethnicity: "Asian or Asian British: Bangladeshi"), OpenStruct.new(id: 10, value: "Asian or Asian British: Bangladeshi"),
OpenStruct.new(id: 11, ethnicity: "Asian or Asian British: Chinese"), OpenStruct.new(id: 11, value: "Asian or Asian British: Chinese"),
OpenStruct.new(id: 12, ethnicity: "Asian or Asian British: Other"), OpenStruct.new(id: 12, value: "Asian or Asian British: Other"),
OpenStruct.new(id: 13, ethnicity: "Black: Caribbean"), OpenStruct.new(id: 13, value: "Black: Caribbean"),
OpenStruct.new(id: 14, ethnicity: "Black: African"), OpenStruct.new(id: 14, value: "Black: African"),
OpenStruct.new(id: 15, ethnicity: "Black: Other"), OpenStruct.new(id: 15, value: "Black: Other"),
OpenStruct.new(id: 16, ethnicity: "Other Ethnic Group: Arab"), OpenStruct.new(id: 16, value: "Other Ethnic Group: Arab"),
OpenStruct.new(id: 17, ethnicity: "Other Ethnic Group: Other"), OpenStruct.new(id: 17, value: "Other Ethnic Group: Other"),
OpenStruct.new(id: 18, ethnicity: "Prefer not to say") OpenStruct.new(id: 18, value: "Prefer not to say")
] %> ] %>
<% previous_question = Form.previous_question("tenant_ethnic_group") %> <% previous_question = Form.previous_question("tenant_ethnic_group") %>
@ -30,7 +30,7 @@
<%= turbo_frame_tag "case_log_form", target: "_top" do %> <%= turbo_frame_tag "case_log_form", target: "_top" do %>
<%= form_with action: '/case_logs', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> <%= form_with action: '/case_logs', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_collection_radio_buttons :tenant_ethnic_group, ethnic_groups, :id, legend: { text: "What is the tenant’s ethnic group?", size: "l" } %> <%= f.govuk_collection_radio_buttons :tenant_ethnic_group, ethnic_groups, :id, :value, legend: { text: "What is the tenant’s ethnic group?", size: "l" } %>
<%= f.hidden_field :previous_question, value: :tenant_ethnic_group %> <%= f.hidden_field :previous_question, value: :tenant_ethnic_group %>
<%= f.hidden_field :case_log_id, value: case_log_id %> <%= f.hidden_field :case_log_id, value: case_log_id %>
<%= f.govuk_submit "Save and continue" %> <%= f.govuk_submit "Save and continue" %>

10
app/views/form/questions/tenant_gender.html.erb

@ -1,8 +1,8 @@
<% genders = [ <% genders = [
OpenStruct.new(id: 0, name: "Male"), OpenStruct.new(id: 0, value: "Male"),
OpenStruct.new(id: 1, name: "Female"), OpenStruct.new(id: 1, value: "Female"),
OpenStruct.new(id: 2, name: "Non-binary"), OpenStruct.new(id: 2, value: "Non-binary"),
OpenStruct.new(id: 3, name: "Prefer not to say") OpenStruct.new(id: 3, value: "Prefer not to say")
] %> ] %>
<% previous_question = Form.previous_question("tenant_gender") %> <% previous_question = Form.previous_question("tenant_gender") %>
@ -14,7 +14,7 @@
<%= turbo_frame_tag "case_log_form", target: "_top" do %> <%= turbo_frame_tag "case_log_form", target: "_top" do %>
<%= form_with action: '/case_logs', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> <%= form_with action: '/case_logs', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_collection_radio_buttons :tenant_gender, genders, :id, legend: { text: "Which of these best describes the tenant's gender identity?", size: "l" } %> <%= f.govuk_collection_radio_buttons :tenant_gender, genders, :id, :value, legend: { text: "Which of these best describes the tenant's gender identity?", size: "l" } %>
<%= f.hidden_field :previous_question, value: :tenant_gender %> <%= f.hidden_field :previous_question, value: :tenant_gender %>
<%= f.hidden_field :case_log_id, value: case_log_id %> <%= f.hidden_field :case_log_id, value: case_log_id %>
<%= f.govuk_submit "Save and continue" %> <%= f.govuk_submit "Save and continue" %>

34
app/views/form/questions/tenant_nationality.html.erb

@ -1,20 +1,20 @@
<% nationalities = [ <% nationalities = [
OpenStruct.new(id: 0, nationality: "UK national resident in UK"), OpenStruct.new(id: 0, value: "UK national resident in UK"),
OpenStruct.new(id: 1, nationality: "A current or former reserve in the UK Armed Forces (exc. National Service)"), OpenStruct.new(id: 1, value: "A current or former reserve in the UK Armed Forces (exc. National Service)"),
OpenStruct.new(id: 2, nationality: "UK national returning from residence overseas"), OpenStruct.new(id: 2, value: "UK national returning from residence overseas"),
OpenStruct.new(id: 3, nationality: "Czech Republic"), OpenStruct.new(id: 3, value: "Czech Republic"),
OpenStruct.new(id: 4, nationality: "Estonia"), OpenStruct.new(id: 4, value: "Estonia"),
OpenStruct.new(id: 5, nationality: "Hungary"), OpenStruct.new(id: 5, value: "Hungary"),
OpenStruct.new(id: 6, nationality: "Latvia"), OpenStruct.new(id: 6, value: "Latvia"),
OpenStruct.new(id: 7, nationality: "Lithuania"), OpenStruct.new(id: 7, value: "Lithuania"),
OpenStruct.new(id: 8, nationality: "Poland"), OpenStruct.new(id: 8, value: "Poland"),
OpenStruct.new(id: 9, nationality: "Slovakia"), OpenStruct.new(id: 9, value: "Slovakia"),
OpenStruct.new(id: 10, nationality: "Bulgaria"), OpenStruct.new(id: 10, value: "Bulgaria"),
OpenStruct.new(id: 11, nationality: "Romania"), OpenStruct.new(id: 11, value: "Romania"),
OpenStruct.new(id: 12, nationality: "Ireland"), OpenStruct.new(id: 12, value: "Ireland"),
OpenStruct.new(id: 13, nationality: "Other EU Economic Area (EEA country)"), OpenStruct.new(id: 13, value: "Other EU Economic Area (EEA country)"),
OpenStruct.new(id: 14, nationality: "Any other country"), OpenStruct.new(id: 14, value: "Any other country"),
OpenStruct.new(id: 15, nationality: "Prefer not to say") OpenStruct.new(id: 15, value: "Prefer not to say")
] %> ] %>
<% previous_question = Form.previous_question("tenant_nationality") %> <% previous_question = Form.previous_question("tenant_nationality") %>
@ -26,7 +26,7 @@
<%= turbo_frame_tag "case_log_form", target: "_top" do %> <%= turbo_frame_tag "case_log_form", target: "_top" do %>
<%= form_with action: '/case_logs', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> <%= form_with action: '/case_logs', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_collection_radio_buttons :tenant_nationality, nationalities, :id, legend: { text: "What is the tenant’s ethnic group?", size: "l" } %> <%= f.govuk_collection_radio_buttons :tenant_nationality, nationalities, :id, :value, legend: { text: "What is the tenant’s ethnic group?", size: "l" } %>
<%= f.hidden_field :previous_question, value: :tenant_nationality %> <%= f.hidden_field :previous_question, value: :tenant_nationality %>
<%= f.hidden_field :case_log_id, value: case_log_id %> <%= f.hidden_field :case_log_id, value: case_log_id %>
<%= f.govuk_submit "Save and continue" %> <%= f.govuk_submit "Save and continue" %>

8
spec/features/case_log_spec.rb

@ -56,14 +56,14 @@ RSpec.describe "Test Features" do
visit("/case_logs/#{id}/#{question}") visit("/case_logs/#{id}/#{question}")
case type case type
when "text" when "text"
fill_in("#{question}", with: answer) fill_in(question.to_s, with: answer)
when "radio" when "radio"
choose("#{question.to_s.gsub('_', '-')}-#{answer}-field") choose("#{question.to_s.tr('_', '-')}-#{answer}-field")
else else
fill_in("#{question}", with: answer) fill_in(question.to_s, with: answer)
end end
expect { click_button("Save and continue") }.to change { expect { click_button("Save and continue") }.to change {
case_log.reload.send("#{question}") case_log.reload.send(question.to_s)
}.from(original_value).to(answer) }.from(original_value).to(answer)
end end
end end

Loading…
Cancel
Save