diff --git a/app/models/scheme.rb b/app/models/scheme.rb index dddabc740..405dfe8d6 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -212,7 +212,7 @@ class Scheme < ApplicationRecord required_attributes = attribute_names - %w[id created_at updated_at old_id old_visible_id confirmed end_date sensitive secondary_client_group total_units has_other_client_group] if confirmed == true && required_attributes.any? { |attribute| self[attribute].blank? } - errors.add :base, "Please answer all the required questions" + errors.add :base end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 6564d8e7c..14af424b8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -65,6 +65,8 @@ en: invalid: "Select if this scheme provides for another client group" arrangement_type: invalid: "Select who provides the support services used by this scheme" + base: + invalid: "You must answer all the required questions for this scheme" location: attributes: startdate: diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index 80a72d55c..248ebc002 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -557,13 +557,22 @@ RSpec.describe SchemesController, type: :request do context "when signed in as a data coordinator" do let(:user) { FactoryBot.create(:user, :data_coordinator) } - let(:scheme_to_update) { FactoryBot.create(:scheme, owning_organisation: user.organisation) } + let(:scheme_to_update) { FactoryBot.create(:scheme, owning_organisation: user.organisation, confirmed: nil) } before do sign_in user patch "/schemes/#{scheme_to_update.id}", params: end + context "when confirming the scheme" do + let(:params) { { scheme: { owning_organisation_id: user.organisation.id, arrangement_type: "V", confirmed: true, page: "check-answers" } } } + + it "does not allow the scheme to be confirmed" do + expect(response).to have_http_status(:unprocessable_entity) + expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.base.invalid")) + end + end + context "when params are missing" do let(:params) do { scheme: {