Browse Source

changes to comparison

pull/761/head
Dushan Despotovic 3 years ago
parent
commit
4452ac8ec1
  1. 10
      app/controllers/schemes_controller.rb
  2. 12
      spec/requests/schemes_controller_spec.rb

10
app/controllers/schemes_controller.rb

@ -30,7 +30,7 @@ class SchemesController < ApplicationController
validation_errors scheme_params
if @scheme.errors.empty? && @scheme.save
if scheme_params[:arrangement_type] == "The same organisation that owns the housing stock"
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)
@ -100,9 +100,7 @@ private
def validation_errors(scheme_params)
scheme_params.each_key do |key|
if key == "support_services_provider"
@scheme.errors.add("support_services_provider_before_type_cast".to_sym) if scheme_params[key].to_s.empty?
elsif scheme_params[key].to_s.empty?
if scheme_params[key].to_s.empty?
@scheme.errors.add(key.to_sym)
end
end
@ -143,9 +141,9 @@ private
when "support"
new_location_path
when "details"
if @scheme.arrangement_type == "The same organisation that owns the housing stock"
if @scheme.arrangement_type_before_type_cast == "D"
scheme_primary_client_group_path(@scheme)
elsif @scheme.arrangement_type.present? && @scheme.arrangement_type != "The same organisation that owns the housing stock"
elsif @scheme.arrangement_type.present? && @scheme.arrangement_type_before_type_cast != "D"
scheme_support_services_provider_path(@scheme)
else
scheme_details_path(@scheme)

12
spec/requests/schemes_controller_spec.rb

@ -341,7 +341,7 @@ RSpec.describe SchemesController, type: :request do
sensitive: "1",
scheme_type: "Foyer",
registered_under_care_act: "No",
arrangement_type: "The same organisation that owns the housing stock" } }
arrangement_type: "D" } }
end
before do
@ -378,7 +378,7 @@ RSpec.describe SchemesController, type: :request do
sensitive: "1",
scheme_type: "Foyer",
registered_under_care_act: "No",
support_services_provider_before_type_cast: "1" } }
arrangement_type: "R" } }
end
it "creates a new scheme for user organisation with valid params and renders correct page" do
@ -435,7 +435,7 @@ RSpec.describe SchemesController, type: :request do
scheme_type: "Foyer",
registered_under_care_act: "No",
owning_organisation_id: organisation.id,
arrangement_type: "The same organisation that owns the housing stock" } }
arrangement_type: "D" } }
end
before do
@ -786,7 +786,7 @@ RSpec.describe SchemesController, type: :request do
registered_under_care_act: "No",
page: "details",
owning_organisation_id: organisation.id,
arrangement_type: "The same organisation that owns the housing stock" } }
arrangement_type: "D" } }
end
it "renders confirm secondary group after successful update" do
@ -1043,7 +1043,7 @@ RSpec.describe SchemesController, type: :request do
scheme_type: "Foyer",
registered_under_care_act: "No",
page: "details",
arrangement_type: "The same organisation that owns the housing stock",
arrangement_type: "D",
owning_organisation_id: another_organisation.id } }
end
@ -1060,7 +1060,7 @@ 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(nil)
expect(scheme_to_update.reload.managing_organisation_id).to eq(another_organisation.id)
end
context "when updating from check answers page" do

Loading…
Cancel
Save