Browse Source

test: address failing tests

pull/1073/head
natdeanlewissoftwire 4 years ago
parent
commit
e5b667c42c
  1. 4
      app/controllers/organisation_relationships_controller.rb
  2. 2
      app/models/organisation_relationship.rb

4
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

2
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

Loading…
Cancel
Save