diff --git a/app/admin/organisations.rb b/app/admin/organisations.rb
index 129aa8ff9..a9e7fb17d 100644
--- a/app/admin/organisations.rb
+++ b/app/admin/organisations.rb
@@ -2,7 +2,7 @@ ActiveAdmin.register Organisation do
permit_params do
permitted = %i[name
phone
- providertype
+ provider_type
address_line1
address_line2
postcode
@@ -28,8 +28,4 @@ ActiveAdmin.register Organisation do
column :managing_agents
actions
end
-
- before_save do |org|
- org.provider_type = params[:organisation][:provider_type]
- end
end
diff --git a/app/models/form/question.rb b/app/models/form/question.rb
index a6e1ec2b9..220ddd3b4 100644
--- a/app/models/form/question.rb
+++ b/app/models/form/question.rb
@@ -113,7 +113,7 @@ class Form::Question
else
value.to_s
end
- label || value
+ label || value.to_s
end
def value_is_yes?(value)
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
index 9cefe2a6c..b13a9d075 100644
--- a/app/models/organisation.rb
+++ b/app/models/organisation.rb
@@ -12,6 +12,8 @@ class Organisation < ApplicationRecord
enum provider_type: PROVIDER_TYPE
+ validates :provider_type, presence: true
+
def case_logs
CaseLog.for_organisation(self)
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 14b5ea456..0e63f2e5a 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -15,6 +15,7 @@ org = Organisation.create!(
holds_own_stock: false,
other_stock_owners: "None",
managing_agents: "None",
+ provider_type: "LA",
)
User.create!(
email: "test@example.com",
diff --git a/spec/controllers/admin/organisations_controller_spec.rb b/spec/controllers/admin/organisations_controller_spec.rb
index 9ed4dea9d..f639a3b7e 100644
--- a/spec/controllers/admin/organisations_controller_spec.rb
+++ b/spec/controllers/admin/organisations_controller_spec.rb
@@ -26,7 +26,7 @@ describe Admin::OrganisationsController, type: :controller do
end
describe "Create organisation" do
- let(:params) { { organisation: { name: "DLUHC" } } }
+ let(:params) { { organisation: { name: "DLUHC", provider_type: "LA" } } }
it "creates a organisation" do
expect { post :create, session: valid_session, params: params }.to change(Organisation, :count).by(1)
diff --git a/spec/factories/organisation.rb b/spec/factories/organisation.rb
index a81c268eb..593bba4ae 100644
--- a/spec/factories/organisation.rb
+++ b/spec/factories/organisation.rb
@@ -3,7 +3,7 @@ FactoryBot.define do
name { "DLUHC" }
address_line1 { "2 Marsham Street" }
address_line2 { "London" }
- provider_type { 2 }
+ provider_type { "LA" }
postcode { "SW1P 4DF" }
created_at { Time.zone.now }
updated_at { Time.zone.now }
diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml
index 249d52c4f..7a88549ae 100644
--- a/spec/fixtures/exports/case_logs.xml
+++ b/spec/fixtures/exports/case_logs.xml
@@ -121,7 +121,7 @@
{managing_org_id}
2
1
- 5
+ 7
1
1
false
diff --git a/spec/models/form/question_spec.rb b/spec/models/form/question_spec.rb
index 2f2a65218..dd23d3ec6 100644
--- a/spec/models/form/question_spec.rb
+++ b/spec/models/form/question_spec.rb
@@ -118,7 +118,7 @@ RSpec.describe Form::Question, type: :model do
context "when the saved answer is not in the value map" do
it "displays the saved answer umapped" do
- expect(question.label_from_value(9999)).to eq(9999)
+ expect(question.label_from_value(9999)).to eq("9999")
end
end
end
@@ -139,7 +139,7 @@ RSpec.describe Form::Question, type: :model do
context "when the saved answer is not in the value map" do
it "displays the saved answer umapped" do
- expect(question.label_from_value(9999)).to eq(9999)
+ expect(question.label_from_value(9999)).to eq("9999")
end
end
end
diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb
index 9aa6c75cd..89cdb61bd 100644
--- a/spec/models/organisation_spec.rb
+++ b/spec/models/organisation_spec.rb
@@ -13,6 +13,11 @@ RSpec.describe Organisation, type: :model do
expect(organisation.users.first).to eq(user)
end
+ it "validates provider_type presence" do
+ expect { FactoryBot.create(:organisation, provider_type: nil) }
+ .to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Provider type can't be blank")
+ end
+
context "with case logs" do
let(:other_organisation) { FactoryBot.create(:organisation) }
let!(:owned_case_log) do