Browse Source

fixed check answers page

pull/730/head
JG 3 years ago
parent
commit
caba67fa99
  1. 5
      app/models/scheme.rb
  2. 55
      app/views/schemes/check_answers.html.erb
  3. 2
      app/views/schemes/primary_client_group.html.erb
  4. 16
      spec/features/schemes_spec.rb

5
app/models/scheme.rb

@ -102,10 +102,11 @@ class Scheme < ApplicationRecord
{ name: "Service code", value: id_to_display },
{ name: "Name", value: service_name },
{ name: "Confidential information", value: sensitive },
{ name: "Housing stock owned by", value: owning_organisation.name },
{ name: "Managed by", value: managing_organisation&.name },
{ name: "Type of scheme", value: scheme_type },
{ name: "Registered under Care Standards Act 2000", value: registered_under_care_act },
{ name: "Housing stock owned by", value: owning_organisation.name },
{ name: "Support provided by", value: support_services_provider },
{ name: "Organisation providing support", value: managing_organisation&.name },
]
end

55
app/views/schemes/check_answers.html.erb

@ -1,5 +1,4 @@
<% content_for :title, "Check your answers before creating this scheme" %>
<%= render partial: "organisations/headings", locals: { main: "Check your changes before creating this scheme", sub: @scheme.service_name } %>
<div class="govuk-grid-row">
@ -7,13 +6,57 @@
<%= govuk_tabs(title: "Check your answers before creating this scheme") do |component| %>
<% component.tab(label: "Scheme") do %>
<%= govuk_summary_list do |summary_list| %>
<% @scheme.display_attributes.each do |attr| %>
<% next if current_user.data_coordinator? && attr[:name] == ("Housing stock owned by") %>
<% next if @scheme.has_other_client_group == "No" && attr[:name] == ("Secondary client group") %>
<% @scheme.check_details_attributes.each do |attr| %>
<% next if current_user.data_coordinator? && attr[:name] == ("owned by") %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s } %>
<% row.value { details_html(attr) } %>
<% row.action(
text: "Change",
href: scheme_details_path(scheme_id: @scheme.id, check_answers: true),
) %>
<% end %>
<% end %>
<% @scheme.check_primary_client_attributes.each do |attr| %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s } %>
<% row.value { details_html(attr) } %>
<% row.action(
text: "Change",
href: scheme_primary_client_group_path(scheme_id: @scheme.id, check_answers: true),
) %>
<% end %>
<% end %>
<% @scheme.check_secondary_client_confirmation_attributes.each do |attr| %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s } %>
<% row.value { details_html(attr) } %>
<% row.action(
text: "Change",
href: scheme_confirm_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true),
) %>
<% end %>
<% end %>
<% if @scheme.has_other_client_group == "Yes" %>
<% @scheme.check_secondary_client_attributes.each do |attr| %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s } %>
<% row.value { details_html(attr) } %>
<% row.action(
text: "Change",
href: scheme_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true),
) %>
<% end %>
<% end %>
<% end %>
<% @scheme.check_support_attributes.each do |attr| %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name].eql?("Registered under Care Standards Act 2000") ? "Registered under Care Standards Act 2000" : attr[:name].to_s.humanize } %>
<% row.key { attr[:name].to_s } %>
<% row.value { details_html(attr) } %>
<% row.action(text: "Change", href: scheme_edit_name_path(scheme_id: @scheme.id, check_answers: true)) if attr[:edit] %>
<% row.action(
text: "Change",
href: scheme_support_path(scheme_id: @scheme.id, check_answers: true),
) %>
<% end %>
<% end %>
<% end %>

2
app/views/schemes/primary_client_group.html.erb

@ -5,7 +5,7 @@
<% elsif request.referer&.include?("provider") %>
<% back_button_path = scheme_support_services_provider_path(@scheme) %>
<% elsif request.query_parameters["check_answers"] %>
<% back_button_path = scheme_check_asnwers_path(@scheme) %>
<% back_button_path = scheme_check_answers_path(@scheme) %>
<% end %>
<% content_for :before_content do %>

16
spec/features/schemes_spec.rb

@ -479,19 +479,19 @@ RSpec.describe "Schemes scheme Features" do
context "when changing answers" do
it "displays change links" do
assert_selector "a", text: "Change", count: 3
assert_selector "a", text: "Change", count: 13
end
context "when changing details" do
before do
click_link("Change", href: "/schemes/#{scheme.id}/edit-name?check_answers=true", match: :first)
click_link("Change", href: "/schemes/#{scheme.id}/details?check_answers=true", match: :first)
end
it "allows changing details questions" do
expect(page).to have_current_path("/schemes/#{scheme.id}/edit-name?check_answers=true")
expect(page).to have_current_path("/schemes/#{scheme.id}/details?check_answers=true")
fill_in "Scheme name", with: "Example"
click_button "Save changes"
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
expect(page).to have_content "Example"
@ -776,19 +776,19 @@ RSpec.describe "Schemes scheme Features" do
context "when changing answers" do
it "displays change links" do
assert_selector "a", text: "Change", count: 3
assert_selector "a", text: "Change", count: 13
end
context "when changing details" do
before do
click_link("Change", href: "/schemes/#{scheme.id}/edit-name?check_answers=true", match: :first)
click_link("Change", href: "/schemes/#{scheme.id}/details?check_answers=true", match: :first)
end
it "allows changing details questions" do
expect(page).to have_current_path("/schemes/#{scheme.id}/edit-name?check_answers=true")
expect(page).to have_current_path("/schemes/#{scheme.id}/details?check_answers=true")
fill_in "Scheme name", with: "Example"
click_button "Save changes"
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
expect(page).to have_content "Example"

Loading…
Cancel
Save