Browse Source

Fixed failed scheme editing (#716)

Co-authored-by: Stéphane Meny <smeny@users.noreply.github.com>
pull/718/head
J G 3 years ago committed by GitHub
parent
commit
19bb7e98fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/controllers/schemes_controller.rb
  2. 6
      app/views/schemes/details.html.erb
  3. 3
      config/locales/en.yml
  4. 2
      spec/requests/schemes_controller_spec.rb

2
app/controllers/schemes_controller.rb

@ -30,7 +30,7 @@ class SchemesController < ApplicationController
render "schemes/primary_client_group"
else
@scheme.errors.add(:owning_organisation_id, message: @scheme.errors[:organisation])
@scheme.errors.delete(:organisation)
@scheme.errors.delete(:owning_organisation)
render :new, status: :unprocessable_entity
end
end

6
app/views/schemes/details.html.erb

@ -27,10 +27,10 @@
<% null_option = [OpenStruct.new(id: "", name: "Select an option")] %>
<% organisations = Organisation.all.map { |org| OpenStruct.new(id: org.id, name: org.name) } %>
<% stock_org_answer_options = null_option + organisations %>
<% managing_org_answer_options = null_option + organisations %>
<%= f.govuk_collection_select :managing_organisation_id,
organisations,
managing_org_answer_options,
:id,
:name,
label: { text: "Which organisation manages this scheme?", size: "m" },
@ -39,7 +39,7 @@
<% if current_user.support? %>
<%= f.govuk_collection_select :owning_organisation_id,
stock_org_answer_options,
organisations,
:id,
:name,
label: { text: "Which organisation owns the housing stock for this scheme?", size: "m" },

3
config/locales/en.yml

@ -43,8 +43,9 @@ en:
models:
scheme:
attributes:
owning_organisation:
owning_organisation_id:
required: "Enter the existing organisation’s name"
invalid: "Enter the existing organisation’s name"
validations:
organisation:

2
spec/requests/schemes_controller_spec.rb

@ -406,7 +406,7 @@ RSpec.describe SchemesController, type: :request do
it "displays the new page with an error message" do
post "/schemes", params: params
expect(response).to have_http_status(:unprocessable_entity)
expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.owning_organisation.required"))
expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.owning_organisation_id.required"))
end
end
end

Loading…
Cancel
Save