From e5b667c42cd0b490cb8220c9c5f3c56de4f4dae9 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Tue, 13 Dec 2022 10:04:19 +0000 Subject: [PATCH] test: address failing tests --- app/controllers/organisation_relationships_controller.rb | 4 ++-- app/models/organisation_relationship.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/organisation_relationships_controller.rb b/app/controllers/organisation_relationships_controller.rb index 145b61066..9aa93c37c 100644 --- a/app/controllers/organisation_relationships_controller.rb +++ b/app/controllers/organisation_relationships_controller.rb @@ -41,7 +41,7 @@ class OrganisationRelationshipsController < ApplicationController def create_housing_provider @organisation_relationship = organisation.parent_organisation_relationships.new(organisation_relationship_params) - if @organisation_relationship.save + if @organisation_relationship.save(context: :housing_provider) flash[:notice] = "#{@organisation_relationship.parent_organisation.name} is now one of #{current_user.data_coordinator? ? 'your' : "this organisation's"} housing providers" redirect_to housing_providers_organisation_path else @@ -118,7 +118,7 @@ private end def authenticate_scope! - if current_user.organisation != organisation && !current_user.support? + if current_user.organisation != Organisation.find(params[:id]) && !current_user.support? render_not_found end end diff --git a/app/models/organisation_relationship.rb b/app/models/organisation_relationship.rb index e17826dbe..e03b52530 100644 --- a/app/models/organisation_relationship.rb +++ b/app/models/organisation_relationship.rb @@ -5,7 +5,7 @@ class OrganisationRelationship < ApplicationRecord validates :child_organisation_id, presence: { message: "You must choose a managing agent" } validates :parent_organisation_id, uniqueness: { scope: :child_organisation_id, message: "You have already added this housing provider" } validates :child_organisation_id, uniqueness: { scope: :parent_organisation_id, message: "You have already added this managing agent" } - validate :validate_housing_provider_owns_stock + validate :validate_housing_provider_owns_stock, on: :housing_provider private