From 755719115a4d6c696f1d88483b7a49ec22f2efbf Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Thu, 27 Oct 2022 16:31:30 +0100 Subject: [PATCH] refactor: rubocop autocorrect --- app/controllers/organisation_relationships_controller.rb | 6 +++--- spec/requests/organisations_controller_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/organisation_relationships_controller.rb b/app/controllers/organisation_relationships_controller.rb index 7ce66e5c4..7eaf31b72 100644 --- a/app/controllers/organisation_relationships_controller.rb +++ b/app/controllers/organisation_relationships_controller.rb @@ -49,15 +49,15 @@ class OrganisationRelationshipsController < ApplicationController if related_organisation_id.empty? @organisation.errors.add :related_organisation_id, "You must choose a housing provider" @organisations = Organisation.where.not(id: child_organisation_id).pluck(:id, :name) - render 'organisation_relationships/add_housing_provider' + render "organisation_relationships/add_housing_provider" return elsif OrganisationRelationship.exists?(child_organisation_id:, parent_organisation_id:, relationship_type:) @organisation.errors.add :related_organisation_id, "You have already added this housing provider" @organisations = Organisation.where.not(id: child_organisation_id).pluck(:id, :name) - render 'organisation_relationships/add_housing_provider' + render "organisation_relationships/add_housing_provider" return end - create(child_organisation_id:, parent_organisation_id:, relationship_type:) + create!(child_organisation_id:, parent_organisation_id:, relationship_type:) redirect_to housing_providers_organisation_path(related_organisation_id:) end diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb index ed6f7a535..2557d6cb2 100644 --- a/spec/requests/organisations_controller_spec.rb +++ b/spec/requests/organisations_controller_spec.rb @@ -554,7 +554,7 @@ RSpec.describe OrganisationsController, type: :request do it "sets the organisation relationship attributes correctly" do request - expect(OrganisationRelationship.exists?(child_organisation_id: organisation.id, parent_organisation_id: housing_provider.id, relationship_type: OrganisationRelationship::OWNING)).to be_truthy + expect(OrganisationRelationship).to exist(child_organisation_id: organisation.id, parent_organisation_id: housing_provider.id, relationship_type: OrganisationRelationship::OWNING) end it "redirects to the organisation list" do @@ -1421,7 +1421,7 @@ RSpec.describe OrganisationsController, type: :request do it "sets the organisation relationship attributes correctly" do request - expect(OrganisationRelationship.exists?(child_organisation_id: organisation.id, parent_organisation_id: housing_provider.id, relationship_type: OrganisationRelationship::OWNING)).to be_truthy + expect(OrganisationRelationship).to exist(child_organisation_id: organisation.id, parent_organisation_id: housing_provider.id, relationship_type: OrganisationRelationship::OWNING) end it "redirects to the organisation list" do