1628: a scheme's owning organisation must hold stock (#1027)
* feat: start adding scheme validation for when owning org doesn't hold stock
* feat: don't set owning_organisation = nil in validate_owning_organisation
* style: line code
* test: remove redundant test for missing owning org
* test: add test for invalid owning org id (invalid as doesn't hold stock)
* test: add test that including owning org does nothing when user is coordinator
* test: standardise missing params test descriptions in schemes_controller_spec
* test: remove owning org id from required params list for data coordinators
* test: write "support user", not just "support"
* test: fix incorrect test descriptions
* test: test validation raised when updating model with non-stock-owning org
* config: set dummy_org in seeds as holding own stock
* test: test for actual validation string, not the validation lookup
* refactor: change owning_organisation_id: organisation.id to owning_organisation: organisation
* test: move scheme params def onto 1 line
* style: move "validate :validate_owning_organisation" onto new line
context"when the owning organisation is set as a non-stock-owning organisation"do
it"throws the correct validation error"do
expect{scheme.update!({owning_organisation:non_stock_owning_org})}.toraise_error(ActiveRecord::RecordInvalid,/Enter an organisation that owns housing stock/)
@ -566,7 +576,7 @@ RSpec.describe SchemesController, type: :request do
end
end
end
end
context"when missing required scheme params"do
context"when required params are missing"do
let(:params)do
let(:params)do
{scheme:{service_name:"",
{scheme:{service_name:"",
scheme_type:"",
scheme_type:"",
@ -586,13 +596,14 @@ RSpec.describe SchemesController, type: :request do
end
end
end
end
context"when required organisation id param is missing"do
context"when organisation id param refers to a non-stock-owning organisation"do
let(:params){{"scheme"=>{"service_name"=>"qweqwer","sensitive"=>"Yes","owning_organisation_id"=>"","scheme_type"=>"Foyer","registered_under_care_act"=>"Yes – part registered as a care home"}}}