diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index 73fe02f79..d23c3a8ee 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -92,14 +92,12 @@ class SchemesController < ApplicationController validation_errors scheme_params if @scheme.errors.empty? && @scheme.save - if @scheme.arrangement_type_before_type_cast == "D" - redirect_to scheme_primary_client_group_path(@scheme) - else - redirect_to scheme_support_services_provider_path(@scheme) - end + redirect_to scheme_primary_client_group_path(@scheme) else - @scheme.errors.add(:owning_organisation_id, message: @scheme.errors[:organisation]) - @scheme.errors.delete(:owning_organisation) + if @scheme.errors.any? { |error| error.attribute == :owning_organisation } + @scheme.errors.add(:owning_organisation_id, message: @scheme.errors[:organisation]) + @scheme.errors.delete(:owning_organisation) + end render :new, status: :unprocessable_entity end end @@ -182,12 +180,6 @@ class SchemesController < ApplicationController render "schemes/edit_name" end - def support_services_provider - render_not_found and return unless @scheme - - render "schemes/support_services_provider" - end - private def validation_errors(scheme_params) @@ -196,10 +188,6 @@ private @scheme.errors.add(key.to_sym) end end - - if @scheme.arrangement_type_same? && arrangement_type_value(scheme_params[:arrangement_type]) != "D" - @scheme.errors.delete(:managing_organisation_id) - end end def confirm_secondary_page?(page) @@ -209,8 +197,6 @@ private def current_template(page) if page.include?("primary") "schemes/primary_client_group" - elsif page.include?("support-services-provider") - "schemes/support_services_provider" elsif page.include?("confirm") "schemes/confirm_secondary" elsif page.include?("secondary-client") @@ -228,8 +214,6 @@ private def next_page_path(page) case page - when "support-services-provider" - scheme_primary_client_group_path(@scheme) when "primary-client-group" scheme_confirm_secondary_client_group_path(@scheme) when "confirm-secondary" @@ -239,13 +223,7 @@ private when "support" scheme_check_answers_path(@scheme) when "details" - if @scheme.arrangement_type_before_type_cast == "D" - scheme_primary_client_group_path(@scheme) - elsif @scheme.arrangement_type.present? && @scheme.arrangement_type_before_type_cast != "D" - scheme_support_services_provider_path(@scheme) - else - scheme_details_path(@scheme) - end + scheme_primary_client_group_path(@scheme) when "edit-name" scheme_check_answers_path(@scheme) when "check-answers" @@ -257,7 +235,6 @@ private required_params = params.require(:scheme).permit(:service_name, :sensitive, :owning_organisation_id, - :managing_organisation_id, :scheme_type, :registered_under_care_act, :id, @@ -269,14 +246,6 @@ private :intended_stay, :confirmed) - if arrangement_type_changed_to_different_org?(required_params) - required_params[:managing_organisation_id] = nil - end - - if arrangement_type_set_to_same_org?(required_params) - required_params[:managing_organisation_id] = required_params[:owning_organisation_id] || @scheme.owning_organisation_id - end - required_params[:sensitive] = required_params[:sensitive].to_i if required_params[:sensitive] if current_user.data_coordinator? @@ -285,22 +254,6 @@ private required_params end - def arrangement_type_set_to_same_org?(required_params) - return unless @scheme - - arrangement_type_value(required_params[:arrangement_type]) == "D" || (required_params[:arrangement_type].blank? && @scheme.arrangement_type_same?) - end - - def arrangement_type_changed_to_different_org?(required_params) - return unless @scheme - - @scheme.arrangement_type_same? && arrangement_type_value(required_params[:arrangement_type]) != "D" && required_params[:managing_organisation_id].blank? - end - - def arrangement_type_value(key) - key.present? ? Scheme::ARRANGEMENT_TYPE[key.to_sym] : nil - end - def search_term params["search"] end diff --git a/app/helpers/schemes_helper.rb b/app/helpers/schemes_helper.rb index 3cbac5789..0503f88b3 100644 --- a/app/helpers/schemes_helper.rb +++ b/app/helpers/schemes_helper.rb @@ -8,7 +8,6 @@ module SchemesHelper { name: "Registered under Care Standards Act 2000", value: scheme.registered_under_care_act }, { name: "Housing stock owned by", value: scheme.owning_organisation.name, edit: true }, { name: "Support services provided by", value: scheme.arrangement_type }, - { name: "Organisation providing support", value: scheme.managing_organisation&.name }, { name: "Primary client group", value: scheme.primary_client_group }, { name: "Has another client group", value: scheme.has_other_client_group }, { name: "Secondary client group", value: scheme.secondary_client_group }, @@ -25,9 +24,10 @@ module SchemesHelper base_attributes.delete_if { |item| item[:name] == "Housing stock owned by" } end - if scheme.arrangement_type_same? - base_attributes.delete_if { |item| item[:name] == "Organisation providing support" } + if scheme.has_other_client_group == "Yes" + base_attributes.append end + base_attributes end diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index 2584f95ae..d78495016 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -424,10 +424,6 @@ class LettingsLog < Log scheme_owning_organisation&.name end - def scheme_managing_organisation_name - scheme_managing_organisation&.name - end - delegate :postcode, :name, :units, :type_of_unit, :mobility_type, :startdate, prefix: "location", to: :location, allow_nil: true delegate :location_admin_district, to: :location, allow_nil: true diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 94d2b135b..f8cf6bf63 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -1,6 +1,5 @@ class Scheme < ApplicationRecord belongs_to :owning_organisation, class_name: "Organisation" - belongs_to :managing_organisation, optional: true, class_name: "Organisation" has_many :locations, dependent: :delete_all has_many :lettings_logs, class_name: "LettingsLog", dependent: :delete_all has_many :scheme_deactivation_periods, class_name: "SchemeDeactivationPeriod" @@ -127,12 +126,6 @@ class Scheme < ApplicationRecord ] end - def check_support_services_provider_attributes - [ - { name: "Organisation providing support", value: managing_organisation&.name, id: "managing_organisation_id" }, - ] - end - def check_primary_client_attributes [ { name: "Primary client group", value: primary_client_group, id: "primary_client_group" }, @@ -196,10 +189,6 @@ class Scheme < ApplicationRecord Scheme.intended_stays.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: hints[key.to_sym]) } end - def arrangement_type_same? - arrangement_type.present? && ARRANGEMENT_TYPE[arrangement_type.to_sym] == "D" - end - def validate_confirmed required_attributes = attribute_names - %w[id created_at updated_at old_id old_visible_id confirmed end_date sensitive secondary_client_group total_units has_other_client_group deactivation_date deactivation_date_type] diff --git a/app/services/csv/lettings_log_csv_service.rb b/app/services/csv/lettings_log_csv_service.rb index d084bfaa1..cd4ab0041 100644 --- a/app/services/csv/lettings_log_csv_service.rb +++ b/app/services/csv/lettings_log_csv_service.rb @@ -42,7 +42,7 @@ module Csv metadata_fields = %w[id status created_at updated_at created_by_name is_dpo owning_organisation_name managing_organisation_name collection_start_year] metadata_id_fields = %w[managing_organisation_id owning_organisation_id created_by_id] scheme_and_location_ids = %w[scheme_id location_id] - scheme_attributes = %w[scheme_code scheme_service_name scheme_sensitive scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_managing_organisation_name scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at] + scheme_attributes = %w[scheme_code scheme_service_name scheme_sensitive scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at] location_attributes = %w[location_code location_postcode location_name location_units location_type_of_unit location_mobility_type location_admin_district location_startdate] intersecting_attributes = ordered_form_questions & LettingsLog.attribute_names - scheme_and_location_ids remaining_attributes = LettingsLog.attribute_names - intersecting_attributes - scheme_and_location_ids diff --git a/app/services/imports/scheme_import_service.rb b/app/services/imports/scheme_import_service.rb index e7440d393..b0b8f3ceb 100644 --- a/app/services/imports/scheme_import_service.rb +++ b/app/services/imports/scheme_import_service.rb @@ -9,7 +9,6 @@ module Imports if attributes["status"] == "Approved" Scheme.create!( owning_organisation_id: attributes["owning_organisation_id"], - managing_organisation_id: attributes["managing_organisation_id"], service_name: attributes["service_name"], arrangement_type: attributes["arrangement_type"], old_id: attributes["old_id"], @@ -49,12 +48,6 @@ module Imports attributes["arrangement_type"] = string_or_nil(xml_doc, "arrangement_type") attributes["owning_org_old_id"] = string_or_nil(xml_doc, "institution") attributes["owning_organisation_id"] = find_owning_organisation_id(attributes["owning_org_old_id"]) - attributes["management_org_old_visible_id"] = safe_string_as_integer(xml_doc, "agent") - attributes["managing_organisation_id"] = find_managing_organisation_id(attributes["management_org_old_visible_id"]) - - if attributes["arrangement_type"] == "D" && attributes["managing_organisation_id"].nil? - attributes["managing_organisation_id"] = attributes["owning_organisation_id"] - end attributes end @@ -65,14 +58,5 @@ module Imports organisation.id end - - def find_managing_organisation_id(old_visible_id) - return unless old_visible_id - - organisation = Organisation.find_by(old_visible_id:) - raise "Organisation not found with legacy visible ID #{old_visible_id}" if organisation.nil? - - organisation.id - end end end diff --git a/app/services/imports/scheme_location_import_service.rb b/app/services/imports/scheme_location_import_service.rb index 4a4292883..ab5faad27 100644 --- a/app/services/imports/scheme_location_import_service.rb +++ b/app/services/imports/scheme_location_import_service.rb @@ -38,7 +38,6 @@ module Imports end_date: attributes["end_date"], # These values were set by the scheme import (management groups) owning_organisation_id: source_scheme.owning_organisation_id, - managing_organisation_id: source_scheme.managing_organisation_id, service_name: source_scheme.service_name, arrangement_type: source_scheme.arrangement_type, old_id: source_scheme.old_id, diff --git a/app/views/schemes/check_answers.html.erb b/app/views/schemes/check_answers.html.erb index 806b8838a..9dbb68bfd 100644 --- a/app/views/schemes/check_answers.html.erb +++ b/app/views/schemes/check_answers.html.erb @@ -12,11 +12,6 @@ <% next if current_user.data_coordinator? && attr[:name] == ("owned by") %> <%= render partial: "scheme_summary_list_row", locals: { scheme: @scheme, attribute: attr, change_link: @scheme.confirmed? ? scheme_edit_name_path(@scheme) : scheme_details_path(@scheme, check_answers: true) } %> <% end %> - <% if !@scheme.arrangement_type_same? %> - <% @scheme.check_support_services_provider_attributes.each do |attr| %> - <%= render partial: "scheme_summary_list_row", locals: { scheme: @scheme, attribute: attr, change_link: scheme_support_services_provider_path(@scheme, check_answers: true) } %> - <% end %> - <% end %> <% @scheme.check_primary_client_attributes.each do |attr| %> <%= render partial: "scheme_summary_list_row", locals: { scheme: @scheme, attribute: attr, change_link: scheme_primary_client_group_path(@scheme, check_answers: true) } %> <% end %> diff --git a/app/views/schemes/primary_client_group.html.erb b/app/views/schemes/primary_client_group.html.erb index f956884bb..610e916f4 100644 --- a/app/views/schemes/primary_client_group.html.erb +++ b/app/views/schemes/primary_client_group.html.erb @@ -2,8 +2,6 @@ <% if request.referer&.include?("new") || request.referer&.include?("details") %> <% back_button_path = scheme_details_path(@scheme) %> -<% 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_answers_path(@scheme) %> <% end %> diff --git a/app/views/schemes/support_services_provider.html.erb b/app/views/schemes/support_services_provider.html.erb deleted file mode 100644 index cf1891ef0..000000000 --- a/app/views/schemes/support_services_provider.html.erb +++ /dev/null @@ -1,34 +0,0 @@ -<% content_for :title, "Which organisation provides the support services used by this scheme?" %> - -<% content_for :before_content do %> - <%= govuk_back_link( - text: "Back", - href: request.query_parameters["check_answers"] ? "/schemes/#{@scheme.id}/check-answers" : "/schemes/#{@scheme.id}/details", - ) %> -<% end %> - -<%= form_for(@scheme, method: :patch) do |f| %> -
-
- <%= f.govuk_error_summary %> - - <% null_option = [OpenStruct.new(id: "", name: "Select an option")] %> - <% organisations = Organisation.all.map { |org| OpenStruct.new(id: org.id, name: org.name) } %> - <% managing_org_answer_options = null_option + organisations %> - - <%= f.govuk_collection_select :managing_organisation_id, - managing_org_answer_options, - :id, - :name, - label: { text: "Which organisation provides the support services used by this scheme?", size: "m" }, - options: { required: true }, - "data-controller": %w[accessible-autocomplete conditional-filter] %> - - <%= f.hidden_field :page, value: "support-services-provider" %> - <% if request.query_parameters["check_answers"] %> - <%= f.hidden_field :check_answers, value: "true" %> - <% end %> - <%= f.govuk_submit "Save and continue" %> -
-
-<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 2bc894b0d..788b3a710 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -71,8 +71,6 @@ en: attributes: owning_organisation_id: invalid: "Enter the name of the organisation that owns the housing stock" - managing_organisation_id: - invalid: "Enter the name of the organisation that manages the housing stock" service_name: invalid: "Enter the name of the scheme" scheme_type: diff --git a/db/migrate/20230111134640_remove_managing_organisation_id_from_schemes.rb b/db/migrate/20230111134640_remove_managing_organisation_id_from_schemes.rb new file mode 100644 index 000000000..caaebedd5 --- /dev/null +++ b/db/migrate/20230111134640_remove_managing_organisation_id_from_schemes.rb @@ -0,0 +1,11 @@ +class RemoveManagingOrganisationIdFromSchemes < ActiveRecord::Migration[7.0] + def up + change_table :schemes, bulk: true do |t| + t.remove :managing_organisation_id + end + end + + def down + add_reference :schemes, :managing_organisation_id, foreign_key: { to_table: :organisations } + end +end diff --git a/db/schema.rb b/db/schema.rb index 85c088b66..df7cdb35b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -489,14 +489,14 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_13_125117) do t.integer "hhtype" t.integer "fromprop" t.integer "socprevten" + t.integer "mortgagelender" + t.string "mortgagelenderother" t.integer "mortlen" t.string "pcode1" t.string "pcode2" t.integer "pcodenk" t.string "postcode_full" t.boolean "is_la_inferred" - t.integer "mortgagelender" - t.string "mortgagelenderother" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" @@ -526,13 +526,11 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_13_125117) do t.string "intended_stay" t.datetime "end_date" t.integer "has_other_client_group" - t.bigint "managing_organisation_id" t.string "arrangement_type" t.string "old_id" t.string "old_visible_id" t.integer "total_units" t.boolean "confirmed" - t.index ["managing_organisation_id"], name: "index_schemes_on_managing_organisation_id" t.index ["owning_organisation_id"], name: "index_schemes_on_owning_organisation_id" end @@ -597,7 +595,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_13_125117) do add_foreign_key "organisation_relationships", "organisations", column: "child_organisation_id" add_foreign_key "organisation_relationships", "organisations", column: "parent_organisation_id" add_foreign_key "sales_logs", "organisations", column: "owning_organisation_id", on_delete: :cascade - add_foreign_key "schemes", "organisations", column: "managing_organisation_id" add_foreign_key "schemes", "organisations", column: "owning_organisation_id", on_delete: :cascade add_foreign_key "users", "organisations", on_delete: :cascade end diff --git a/db/seeds.rb b/db/seeds.rb index ac3db6482..cf6895501 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -236,7 +236,6 @@ unless Rails.env.test? primary_client_group: "O", secondary_client_group: "H", owning_organisation: org, - managing_organisation: org, arrangement_type: "D", confirmed: true, created_at: Time.zone.now, @@ -252,7 +251,6 @@ unless Rails.env.test? primary_client_group: "D", secondary_client_group: "E", owning_organisation: org, - managing_organisation: org, arrangement_type: "D", confirmed: true, created_at: Time.zone.now, @@ -268,7 +266,6 @@ unless Rails.env.test? primary_client_group: "G", secondary_client_group: "R", owning_organisation: dummy_org, - managing_organisation: dummy_org, arrangement_type: "D", confirmed: true, created_at: Time.zone.now, diff --git a/spec/factories/scheme.rb b/spec/factories/scheme.rb index 031d9b8c1..6c08e269d 100644 --- a/spec/factories/scheme.rb +++ b/spec/factories/scheme.rb @@ -10,7 +10,6 @@ FactoryBot.define do primary_client_group { %w[O H M L A G F B D E I S N R Q P X].sample } secondary_client_group { %w[O H M L A G F B D E I S N R Q P X].sample } owning_organisation { FactoryBot.create(:organisation) } - managing_organisation { FactoryBot.create(:organisation) } confirmed { true } created_at { Time.zone.local(2021, 4, 1) } trait :export do diff --git a/spec/features/form/accessible_autocomplete_spec.rb b/spec/features/form/accessible_autocomplete_spec.rb index 9c7c1b9ea..fd8102dcc 100644 --- a/spec/features/form/accessible_autocomplete_spec.rb +++ b/spec/features/form/accessible_autocomplete_spec.rb @@ -61,7 +61,7 @@ RSpec.describe "Accessible Automcomplete" do end context "when searching schemes" do - let(:scheme) { FactoryBot.create(:scheme, owning_organisation_id: lettings_log.created_by.organisation_id, managing_organisation_id: lettings_log.created_by.organisation_id, primary_client_group: "Q", secondary_client_group: "P") } + let(:scheme) { FactoryBot.create(:scheme, owning_organisation_id: lettings_log.created_by.organisation_id, primary_client_group: "Q", secondary_client_group: "P") } before do FactoryBot.create(:location, scheme:, postcode: "W6 0ST") diff --git a/spec/features/schemes_helpers.rb b/spec/features/schemes_helpers.rb index 68c5d9dee..4ce1063c1 100644 --- a/spec/features/schemes_helpers.rb +++ b/spec/features/schemes_helpers.rb @@ -38,11 +38,16 @@ module SchemesHelpers click_button "Save and continue" end - def fill_in_and_save_secondary_client_group_confirmation + def fill_in_and_save_secondary_client_group_confirmation_yes choose "Yes" click_button "Save and continue" end + def fill_in_and_save_secondary_client_group_confirmation_no + choose "No" + click_button "Save and continue" + end + def fill_in_and_save_secondary_client_group choose "Offenders and people at risk of offending" click_button "Save and continue" @@ -97,8 +102,15 @@ module SchemesHelpers def create_and_save_a_scheme fill_in_and_save_scheme_details fill_in_and_save_primary_client_group - fill_in_and_save_secondary_client_group_confirmation + fill_in_and_save_secondary_client_group_confirmation_yes fill_in_and_save_secondary_client_group fill_in_and_save_support end + + def create_and_save_a_scheme_no_secondary_client_group + fill_in_and_save_scheme_details + fill_in_and_save_primary_client_group + fill_in_and_save_secondary_client_group_confirmation_no + fill_in_and_save_support + end end diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index 4d8d460b9..c51a5eea5 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -423,14 +423,14 @@ RSpec.describe "Schemes scheme Features" do it "allows selecting secondary client group if the scheme provides for it" do fill_in_and_save_scheme_details fill_in_and_save_primary_client_group - fill_in_and_save_secondary_client_group_confirmation + fill_in_and_save_secondary_client_group_confirmation_yes expect(page).to have_content "What is the other client group?" end it "allows amending secondary client group confirmation question after navigating from secondary client group question" do fill_in_and_save_scheme_details fill_in_and_save_primary_client_group - fill_in_and_save_secondary_client_group_confirmation + fill_in_and_save_secondary_client_group_confirmation_yes click_link "Back" expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group") expect(page).to have_content "Does this scheme provide for another client group?" @@ -439,7 +439,7 @@ RSpec.describe "Schemes scheme Features" do it "returns to the secondary group details question after amending secondary group details confirmation" do fill_in_and_save_scheme_details fill_in_and_save_primary_client_group - fill_in_and_save_secondary_client_group_confirmation + fill_in_and_save_secondary_client_group_confirmation_yes click_link "Back" click_button "Save and continue" expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group") @@ -448,7 +448,7 @@ RSpec.describe "Schemes scheme Features" do it "allows selecting the level of support" do fill_in_and_save_scheme_details fill_in_and_save_primary_client_group - fill_in_and_save_secondary_client_group_confirmation + fill_in_and_save_secondary_client_group_confirmation_yes fill_in_and_save_secondary_client_group expect(page).to have_content "What support does this scheme provide?" end @@ -456,7 +456,7 @@ RSpec.describe "Schemes scheme Features" do it "allows amending secondary client group question after navigating from level of support" do fill_in_and_save_scheme_details fill_in_and_save_primary_client_group - fill_in_and_save_secondary_client_group_confirmation + fill_in_and_save_secondary_client_group_confirmation_yes fill_in_and_save_secondary_client_group click_link "Back" expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group") @@ -466,7 +466,7 @@ RSpec.describe "Schemes scheme Features" do it "returns to the level of support question after amending secondary group details" do fill_in_and_save_scheme_details fill_in_and_save_primary_client_group - fill_in_and_save_secondary_client_group_confirmation + fill_in_and_save_secondary_client_group_confirmation_yes fill_in_and_save_secondary_client_group click_link "Back" click_button "Save and continue" @@ -553,11 +553,11 @@ RSpec.describe "Schemes scheme Features" do context "when changing scheme answers" do before do - create_and_save_a_scheme + create_and_save_a_scheme_no_secondary_client_group end it "displays change links" do - assert_selector "a", text: "Change", count: 12 + assert_selector "a", text: "Change", count: 11 end it "allows changing details questions" do @@ -579,9 +579,10 @@ RSpec.describe "Schemes scheme Features" do end it "indicates if the scheme is not complete" do - click_link("Change", href: "/schemes/#{scheme.id}/details?check_answers=true", match: :first) - choose "Another registered stock owner" + click_link("Change", href: "/schemes/#{scheme.id}/confirm-secondary-client-group?check_answers=true", match: :first) + choose "Yes" click_button "Save and continue" + visit("/schemes/#{scheme.id}/check-answers") expect(page).to have_content("You didn’t answer this question") end end @@ -604,50 +605,25 @@ RSpec.describe "Schemes scheme Features" do context "when I fill in scheme details indicating that supported services provided by a different organisation and I press save I see primary client group section" do let(:scheme) { Scheme.first } - let!(:another_organisation) { FactoryBot.create(:organisation, name: "Another Org") } before do fill_in_and_save_scheme_details({ "housing_stock_owners" => "Another registered stock owner" }) end - it "lets me fill in the managing organisation details" do - expect(page).to have_content "Which organisation provides the support services used by this scheme?" - end - - it "lets me fill in the scheme details after navigating back" do - click_link "Back" - expect(page).to have_current_path("/schemes/#{scheme.id}/details") - expect(page).to have_content "Scheme name" - expect(page).to have_content "This scheme contains confidential information" - expect(page).to have_content "What is this type of scheme?" - expect(page).to have_content "Who provides the support services used by this scheme?" - expect(page).to have_content "Is this scheme registered under the Care Standards Act 2000?" - end - - it "returns to the support service provider after amending the question" do - click_link "Back" - click_button "Save and continue" - expect(page).to have_current_path("/schemes/#{scheme.id}/support-services-provider") - end - it "lets the primary client group to be selected" do - select another_organisation.name, from: "scheme-managing-organisation-id-field" - click_button "Save and continue" expect(page).to have_content "What client group is this scheme intended for?" end context "when changing scheme answers" do before do - select another_organisation.name, from: "scheme-managing-organisation-id-field" - click_button "Save and continue" fill_in_and_save_primary_client_group - fill_in_and_save_secondary_client_group_confirmation + fill_in_and_save_secondary_client_group_confirmation_yes fill_in_and_save_secondary_client_group fill_in_and_save_support end it "displays change links" do - assert_selector "a", text: "Change", count: 13 + assert_selector "a", text: "Change", count: 12 end it "allows changing details questions" do @@ -668,11 +644,11 @@ RSpec.describe "Schemes scheme Features" do expect(page).to have_content "Check your changes before creating this scheme" end - it "keeps the provider answer when swithing between other provider options" do - click_link("Change", href: "/schemes/#{scheme.id}/details?check_answers=true", match: :first) - choose "Another organisation" + it "keeps the provider answer when switching between other provider options" do + click_link("Change", href: "/schemes/#{scheme.id}/confirm-secondary-client-group?check_answers=true", match: :first) + choose "Yes" click_button "Save and continue" - expect(page).to have_content(another_organisation.name) + expect(find_field("Offenders and people at risk of offending")).to be_checked end it "does not display the answer if it's changed to the same support provider" do @@ -1039,7 +1015,7 @@ RSpec.describe "Schemes scheme Features" do context "when selecting a scheme" do let!(:user) { FactoryBot.create(:user, :data_coordinator, last_sign_in_at: Time.zone.now) } - let!(:schemes) { FactoryBot.create_list(:scheme, 5, owning_organisation: user.organisation, managing_organisation: user.organisation, arrangement_type: "The same organisation that owns the housing stock") } + let!(:schemes) { FactoryBot.create_list(:scheme, 5, owning_organisation: user.organisation, arrangement_type: "The same organisation that owns the housing stock") } let(:location) { FactoryBot.create(:location, scheme: schemes[2]) } let!(:lettings_log) { FactoryBot.create(:lettings_log, created_by: user, needstype: 2) } diff --git a/spec/fixtures/files/lettings_logs_download.csv b/spec/fixtures/files/lettings_logs_download.csv index 5881f15ad..ecd41667d 100644 --- a/spec/fixtures/files/lettings_logs_download.csv +++ b/spec/fixtures/files/lettings_logs_download.csv @@ -1,2 +1,2 @@ -id,status,created_at,updated_at,created_by_name,is_dpo,owning_organisation_name,managing_organisation_name,collection_start_year,needstype,renewal,startdate,rent_type_detail,irproduct_other,tenancycode,propcode,age1,sex1,ecstat1,hhmemb,relat2,age2,sex2,retirement_value_check,ecstat2,armedforces,leftreg,illness,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_h,is_previous_la_inferred,prevloc_label,prevloc,illness_type_1,illness_type_2,is_la_inferred,la_label,la,postcode_known,postcode_full,previous_la_known,wchair,preg_occ,cbl,earnings,incfreq,net_income_value_check,benefits,hb,period,brent,scharge,pscharge,supcharg,tcharge,offered,layear,ppostcode_full,mrcdate,declaration,ethnic,national,prevten,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,reservist,startertenancy,tenancylength,tenancy,rsnvac,unittype_gn,beds,waityear,reasonpref,chr,cap,reasonother,housingneeds_f,housingneeds_g,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,purchaser_code,reason,majorrepairs,hbrentshortfall,property_relet,incref,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,renttype,lettype,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,tshortfall,chcharge,ppcodenk,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,has_benefits,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,major_repairs_date_value_check,void_date_value_check,housingneeds_type,housingneeds_other,unresolved,updated_by_id,unittype_sh,scheme_code,scheme_service_name,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_managing_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate -{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,Danny Rojas,No,DLUHC,DLUHC,2021,Supported housing,,2 October 2021,London Affordable Rent,,,,,,,,,,,,,,,,,,,,No,,,,,No,Westminster,E09000033,,SE1 1TE,,No,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,8,0,0,0,,0,,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,0,,,,,,,,,,,,,,,,,,,9,1,,,,,,,,6,{scheme_code},{scheme_service_name},{scheme_sensitive},Missing,No,DLUHC,DLUHC,{scheme_primary_client_group},,{scheme_secondary_client_group},{scheme_support_type},{scheme_intended_stay},2021-04-01 00:00:00 +0100,{location_code},SE1 1TE,Downing Street,20,Bungalow,Fitted with equipment and adaptations,Westminster,{location_startdate} +id,status,created_at,updated_at,created_by_name,is_dpo,owning_organisation_name,managing_organisation_name,collection_start_year,needstype,renewal,startdate,rent_type_detail,irproduct_other,tenancycode,propcode,age1,sex1,ecstat1,hhmemb,relat2,age2,sex2,retirement_value_check,ecstat2,armedforces,leftreg,illness,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_h,is_previous_la_inferred,prevloc_label,prevloc,illness_type_1,illness_type_2,is_la_inferred,la_label,la,postcode_known,postcode_full,previous_la_known,wchair,preg_occ,cbl,earnings,incfreq,net_income_value_check,benefits,hb,period,brent,scharge,pscharge,supcharg,tcharge,offered,layear,ppostcode_full,mrcdate,declaration,ethnic,national,prevten,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,reservist,startertenancy,tenancylength,tenancy,rsnvac,unittype_gn,beds,waityear,reasonpref,chr,cap,reasonother,housingneeds_f,housingneeds_g,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,purchaser_code,reason,majorrepairs,hbrentshortfall,property_relet,incref,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,renttype,lettype,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,tshortfall,chcharge,ppcodenk,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,has_benefits,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,major_repairs_date_value_check,void_date_value_check,housingneeds_type,housingneeds_other,unresolved,updated_by_id,unittype_sh,scheme_code,scheme_service_name,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate +{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,Danny Rojas,No,DLUHC,DLUHC,2021,Supported housing,,2 October 2021,London Affordable Rent,,,,,,,,,,,,,,,,,,,,No,,,,,No,Westminster,E09000033,,SE1 1TE,,No,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,8,0,0,0,,0,,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,0,,,,,,,,,,,,,,,,,,,9,1,,,,,,,,6,{scheme_code},{scheme_service_name},{scheme_sensitive},Missing,No,DLUHC,{scheme_primary_client_group},,{scheme_secondary_client_group},{scheme_support_type},{scheme_intended_stay},2021-04-01 00:00:00 +0100,{location_code},SE1 1TE,Downing Street,20,Bungalow,Fitted with equipment and adaptations,Westminster,{location_startdate} diff --git a/spec/fixtures/files/lettings_logs_download_non_support.csv b/spec/fixtures/files/lettings_logs_download_non_support.csv index c5bfb861e..2db794f49 100644 --- a/spec/fixtures/files/lettings_logs_download_non_support.csv +++ b/spec/fixtures/files/lettings_logs_download_non_support.csv @@ -1,2 +1,2 @@ -id,status,created_at,updated_at,created_by_name,is_dpo,owning_organisation_name,managing_organisation_name,collection_start_year,renewal,startdate,irproduct_other,tenancycode,propcode,age1,sex1,ecstat1,relat2,age2,sex2,ecstat2,armedforces,leftreg,illness,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_h,prevloc_label,illness_type_1,illness_type_2,la_label,postcode_full,wchair,preg_occ,cbl,earnings,incfreq,benefits,hb,period,brent,scharge,pscharge,supcharg,tcharge,offered,layear,ppostcode_full,mrcdate,declaration,ethnic,national,prevten,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,reservist,startertenancy,tenancylength,tenancy,rsnvac,unittype_gn,beds,waityear,reasonpref,chr,cap,reasonother,housingneeds_f,housingneeds_g,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,purchaser_code,reason,majorrepairs,hbrentshortfall,property_relet,incref,unitletas,builtype,voiddate,lettype,nocharge,household_charge,referral,tshortfall,chcharge,ppcodenk,ethnic_group,has_benefits,refused,housingneeds,wchchrg,newprop,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,sheltered,major_repairs_date_value_check,void_date_value_check,housingneeds_type,housingneeds_other,unittype_sh,scheme_code,scheme_service_name,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_managing_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate -{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,Danny Rojas,No,DLUHC,DLUHC,2021,,2 October 2021,,,,,,,,,,,,,,,,,,,,,Westminster,SE1 1TE,No,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,8,0,,,,,,,0,0,,,,,,,,,,,,,,,,,,6,{scheme_code},{scheme_service_name},{scheme_sensitive},Missing,No,DLUHC,DLUHC,{scheme_primary_client_group},,{scheme_secondary_client_group},{scheme_support_type},{scheme_intended_stay},2021-04-01 00:00:00 +0100,{location_code},SE1 1TE,Downing Street,20,Bungalow,Fitted with equipment and adaptations,Westminster,{location_startdate} +id,status,created_at,updated_at,created_by_name,is_dpo,owning_organisation_name,managing_organisation_name,collection_start_year,renewal,startdate,irproduct_other,tenancycode,propcode,age1,sex1,ecstat1,relat2,age2,sex2,ecstat2,armedforces,leftreg,illness,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_h,prevloc_label,illness_type_1,illness_type_2,la_label,postcode_full,wchair,preg_occ,cbl,earnings,incfreq,benefits,hb,period,brent,scharge,pscharge,supcharg,tcharge,offered,layear,ppostcode_full,mrcdate,declaration,ethnic,national,prevten,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,reservist,startertenancy,tenancylength,tenancy,rsnvac,unittype_gn,beds,waityear,reasonpref,chr,cap,reasonother,housingneeds_f,housingneeds_g,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,purchaser_code,reason,majorrepairs,hbrentshortfall,property_relet,incref,unitletas,builtype,voiddate,lettype,nocharge,household_charge,referral,tshortfall,chcharge,ppcodenk,ethnic_group,has_benefits,refused,housingneeds,wchchrg,newprop,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,sheltered,major_repairs_date_value_check,void_date_value_check,housingneeds_type,housingneeds_other,unittype_sh,scheme_code,scheme_service_name,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate +{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,Danny Rojas,No,DLUHC,DLUHC,2021,,2 October 2021,,,,,,,,,,,,,,,,,,,,,Westminster,SE1 1TE,No,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,8,0,,,,,,,0,0,,,,,,,,,,,,,,,,,,6,{scheme_code},{scheme_service_name},{scheme_sensitive},Missing,No,DLUHC,{scheme_primary_client_group},,{scheme_secondary_client_group},{scheme_support_type},{scheme_intended_stay},2021-04-01 00:00:00 +0100,{location_code},SE1 1TE,Downing Street,20,Bungalow,Fitted with equipment and adaptations,Westminster,{location_startdate} diff --git a/spec/helpers/schemes_helper_spec.rb b/spec/helpers/schemes_helper_spec.rb index af9f133ed..77f178f62 100644 --- a/spec/helpers/schemes_helper_spec.rb +++ b/spec/helpers/schemes_helper_spec.rb @@ -98,7 +98,6 @@ RSpec.describe SchemesHelper do scheme_type: 7, registered_under_care_act: 3, owning_organisation:, - managing_organisation:, arrangement_type: "V", primary_client_group: "S", has_other_client_group: 1, @@ -120,7 +119,6 @@ RSpec.describe SchemesHelper do { name: "Registered under Care Standards Act 2000", value: "Yes – registered care home providing personal care" }, { name: "Housing stock owned by", value: "Acme LTD Owning", edit: true }, { name: "Support services provided by", value: "A registered charity or voluntary organisation" }, - { name: "Organisation providing support", value: "Acme LTD Managing" }, { name: "Primary client group", value: "Rough sleepers" }, { name: "Has another client group", value: "Yes" }, { name: "Secondary client group", value: "Refugees (permanent)" }, @@ -140,7 +138,6 @@ RSpec.describe SchemesHelper do { name: "Type of scheme", value: "Housing for older people" }, { name: "Registered under Care Standards Act 2000", value: "Yes – registered care home providing personal care" }, { name: "Support services provided by", value: "A registered charity or voluntary organisation" }, - { name: "Organisation providing support", value: "Acme LTD Managing" }, { name: "Primary client group", value: "Rough sleepers" }, { name: "Has another client group", value: "Yes" }, { name: "Secondary client group", value: "Refugees (permanent)" }, diff --git a/spec/models/form/lettings/questions/scheme_id_spec.rb b/spec/models/form/lettings/questions/scheme_id_spec.rb index 280bca5c8..7d5705935 100644 --- a/spec/models/form/lettings/questions/scheme_id_spec.rb +++ b/spec/models/form/lettings/questions/scheme_id_spec.rb @@ -43,7 +43,7 @@ RSpec.describe Form::Lettings::Questions::SchemeId, type: :model do let(:organisation) { FactoryBot.create(:organisation) } let(:organisation_2) { FactoryBot.create(:organisation) } let(:user) { FactoryBot.create(:user, organisation:) } - let(:scheme) { FactoryBot.create(:scheme, owning_organisation: organisation, managing_organisation: organisation) } + let(:scheme) { FactoryBot.create(:scheme, owning_organisation: organisation) } let(:lettings_log) { FactoryBot.create(:lettings_log, created_by: user, needstype: 2) } before do diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index 17781eede..6d402fa80 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Organisation, type: :model do describe "#new" do let(:user) { FactoryBot.create(:user) } let!(:organisation) { user.organisation } - let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: organisation, managing_organisation: organisation) } + let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: organisation) } it "has expected fields" do expect(organisation.attribute_names).to include("name", "phone", "provider_type") @@ -14,10 +14,6 @@ RSpec.describe Organisation, type: :model do expect(organisation.users.first).to eq(user) end - it "has managed_schemes" do - expect(organisation.managed_schemes.first).to eq(scheme) - end - it "has owned_schemes" do expect(organisation.owned_schemes.first).to eq(scheme) end diff --git a/spec/requests/form_controller_spec.rb b/spec/requests/form_controller_spec.rb index 853bf7978..04a740dc1 100644 --- a/spec/requests/form_controller_spec.rb +++ b/spec/requests/form_controller_spec.rb @@ -250,7 +250,7 @@ RSpec.describe FormController, type: :request do before do locations = create_list(:location, 5) - locations.each { |location| location.scheme.update!(arrangement_type: "The same organisation that owns the housing stock", managing_organisation_id: location.scheme.owning_organisation_id) } + locations.each { |location| location.scheme.update!(arrangement_type: "The same organisation that owns the housing stock") } end it "returns an unfiltered list of schemes" do diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index 5417e79f1..431270767 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -451,7 +451,7 @@ RSpec.describe SchemesController, type: :request do expect { post "/schemes", params: }.to change(Scheme, :count).by(1) follow_redirect! expect(response).to have_http_status(:ok) - expect(page).to have_content("Which organisation provides the support services used by this scheme?") + expect(page).to have_content(" What client group is this scheme intended for?") end it "creates a new scheme for user organisation with valid params" do @@ -557,7 +557,7 @@ RSpec.describe SchemesController, type: :request do expect { post "/schemes", params: }.to change(Scheme, :count).by(1) follow_redirect! expect(response).to have_http_status(:ok) - expect(page).to have_content("Which organisation provides the support services used by this scheme?") + expect(page).to have_content("What client group is this scheme intended for?") end it "creates a new scheme for user organisation with valid params" do @@ -582,6 +582,7 @@ RSpec.describe SchemesController, type: :request do { scheme: { service_name: "", scheme_type: "", registered_under_care_act: "", + owning_organisation_id: nil, arrangement_type: "" } } end @@ -642,11 +643,11 @@ RSpec.describe SchemesController, type: :request do end context "when confirming unfinished scheme" do - let(:params) { { scheme: { owning_organisation_id: user.organisation.id, arrangement_type: "V", confirmed: true, page: "check-answers" } } } + let(:params) { { scheme: { owning_organisation_id: user.organisation.id, arrangement_type: nil, confirmed: true, page: "check-answers" } } } it "does not allow the scheme to be confirmed" do expect(response).to have_http_status(:unprocessable_entity) - expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.managing_organisation_id.invalid")) + expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.arrangement_type.invalid")) end end @@ -654,7 +655,6 @@ RSpec.describe SchemesController, type: :request do let(:params) do { scheme: { service_name: "", - managing_organisation_id: "", primary_client_group: "", secondary_client_group: "", scheme_type: "", @@ -696,36 +696,6 @@ RSpec.describe SchemesController, type: :request do end end - context "when updating support services provider" do - let(:params) { { scheme: { arrangement_type: "Another organisation", managing_organisation_id: organisation.id, page: "support-services-provider" } } } - - it "renders primary client group after successful update" do - follow_redirect! - expect(response).to have_http_status(:ok) - expect(page).to have_content("What client group is this scheme intended for?") - end - - it "updates a scheme with valid params" do - follow_redirect! - expect(scheme_to_update.reload.managing_organisation_id).to eq(organisation.id) - end - - context "when updating from check answers page" do - let(:params) { { scheme: { primary_client_group: "Homeless families with support needs", page: "primary-client-group", check_answers: "true" } } } - - it "renders check answers page after successful update" do - follow_redirect! - expect(response).to have_http_status(:ok) - expect(page).to have_content("Check your changes before creating this scheme") - end - - it "updates a scheme with valid params" do - follow_redirect! - expect(scheme_to_update.reload.primary_client_group).to eq("Homeless families with support needs") - end - end - end - context "when updating primary client group" do let(:params) { { scheme: { primary_client_group: "Homeless families with support needs", page: "primary-client-group" } } } @@ -871,7 +841,6 @@ RSpec.describe SchemesController, type: :request do registered_under_care_act: "No", page: "details", owning_organisation_id: organisation.id, - managing_organisation_id: organisation.id, arrangement_type: "D" } } end @@ -1171,7 +1140,6 @@ RSpec.describe SchemesController, type: :request do expect(scheme_to_update.reload.sensitive).to eq("Yes") expect(scheme_to_update.reload.registered_under_care_act).to eq("No") expect(scheme_to_update.reload.owning_organisation_id).to eq(another_organisation.id) - expect(scheme_to_update.reload.managing_organisation_id).to eq(another_organisation.id) end context "when updating from check answers page" do @@ -1189,7 +1157,6 @@ RSpec.describe SchemesController, type: :request do expect(scheme_to_update.reload.scheme_type).to eq("Foyer") expect(scheme_to_update.reload.sensitive).to eq("Yes") expect(scheme_to_update.reload.registered_under_care_act).to eq("No") - expect(scheme_to_update.reload.managing_organisation_id).to eq(scheme_to_update.owning_organisation_id) end end end diff --git a/spec/services/csv/lettings_log_csv_service_spec.rb b/spec/services/csv/lettings_log_csv_service_spec.rb index 5679d2ad4..95b3069dc 100644 --- a/spec/services/csv/lettings_log_csv_service_spec.rb +++ b/spec/services/csv/lettings_log_csv_service_spec.rb @@ -208,7 +208,6 @@ RSpec.describe Csv::LettingsLogCsvService do scheme_type scheme_registered_under_care_act scheme_owning_organisation_name - scheme_managing_organisation_name scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group diff --git a/spec/services/imports/scheme_import_service_spec.rb b/spec/services/imports/scheme_import_service_spec.rb index 97e9359b5..6a09abb2a 100644 --- a/spec/services/imports/scheme_import_service_spec.rb +++ b/spec/services/imports/scheme_import_service_spec.rb @@ -10,7 +10,6 @@ RSpec.describe Imports::SchemeImportService do let(:scheme_id) { "6d6d7618b58affe2a150a5ef2e9f4765fa6cd05d" } let!(:owning_org) { FactoryBot.create(:organisation, old_org_id: "7c5bd5fb549c09z2c55d9cb90d7ba84927e64618") } - let!(:managing_org) { FactoryBot.create(:organisation, old_visible_id: "456") } def open_file(directory, filename) File.open("#{directory}/#{filename}.xml") @@ -44,7 +43,6 @@ RSpec.describe Imports::SchemeImportService do it "matches expected values" do scheme = scheme_service.create_scheme(scheme_xml) expect(scheme.owning_organisation).to eq(owning_org) - expect(scheme.managing_organisation).to eq(managing_org) expect(scheme.old_id).to eq("6d6d7618b58affe2a150a5ef2e9f4765fa6cd05d") expect(scheme.old_visible_id).to eq("0123") expect(scheme.service_name).to eq("Management Group") @@ -67,10 +65,9 @@ RSpec.describe Imports::SchemeImportService do scheme_xml.at_xpath("//mgmtgroup:agent").content = "" end - it "assigns both owning and managing organisation to the same one" do + it "assigns owning organisation" do scheme = scheme_service.create_scheme(scheme_xml) expect(scheme.owning_organisation).to eq(owning_org) - expect(scheme.managing_organisation).to eq(owning_org) end end end