From 09eb55b0ca382105baf421020c1f643531d4f45a Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Wed, 20 Apr 2022 18:06:04 +0100 Subject: [PATCH 01/20] Create org la relation --- app/models/organisation.rb | 1 + app/models/organisation_la.rb | 2 ++ db/migrate/20220420165451_create_organisation_la.rb | 10 ++++++++++ db/schema.rb | 10 +++++++++- spec/factories/organisation.rb | 7 +++++++ spec/models/organisation_spec.rb | 10 ++++++++++ 6 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 app/models/organisation_la.rb create mode 100644 db/migrate/20220420165451_create_organisation_la.rb diff --git a/app/models/organisation.rb b/app/models/organisation.rb index e9dd7eafe..bd8b77fdc 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -3,6 +3,7 @@ class Organisation < ApplicationRecord has_many :owned_case_logs, class_name: "CaseLog", foreign_key: "owning_organisation_id" has_many :managed_case_logs, class_name: "CaseLog", foreign_key: "managing_organisation_id" has_many :data_protection_confirmations + has_many :organisation_las has_paper_trail diff --git a/app/models/organisation_la.rb b/app/models/organisation_la.rb new file mode 100644 index 000000000..18ab26d26 --- /dev/null +++ b/app/models/organisation_la.rb @@ -0,0 +1,2 @@ +class OrganisationLa < ApplicationRecord +end diff --git a/db/migrate/20220420165451_create_organisation_la.rb b/db/migrate/20220420165451_create_organisation_la.rb new file mode 100644 index 000000000..52cacdfb2 --- /dev/null +++ b/db/migrate/20220420165451_create_organisation_la.rb @@ -0,0 +1,10 @@ +class CreateOrganisationLa < ActiveRecord::Migration[7.0] + def change + create_table :organisation_las do |t| + t.belongs_to :organisation + t.column :ons_code, :string + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index c06c0e7e4..451f16749 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2022_04_11_092231) do +ActiveRecord::Schema[7.0].define(version: 202202071123100) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -256,6 +256,14 @@ ActiveRecord::Schema[7.0].define(version: 2022_04_11_092231) do t.datetime "created_at", default: -> { "CURRENT_TIMESTAMP" } end + create_table "organisation_las", force: :cascade do |t| + t.bigint "organisation_id" + t.string "ons_code" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["organisation_id"], name: "index_organisation_las_on_organisation_id" + end + create_table "organisations", force: :cascade do |t| t.string "name" t.string "phone" diff --git a/spec/factories/organisation.rb b/spec/factories/organisation.rb index 593bba4ae..2bb293968 100644 --- a/spec/factories/organisation.rb +++ b/spec/factories/organisation.rb @@ -8,4 +8,11 @@ FactoryBot.define do created_at { Time.zone.now } updated_at { Time.zone.now } end + + factory :organisation_la do + organisation + ons_code { "E07000041" } + created_at { Time.zone.now } + updated_at { Time.zone.now } + end end diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index 59e0f05d8..d3c09368f 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -29,6 +29,16 @@ RSpec.describe Organisation, type: :model do end end + context "when the organisation only operates in specific local authorities" do + before do + FactoryBot.create(:organisation_la, organisation_id: organisation.id) + end + + it "has local authorities associated" do + expect(organisation.organisation_las.pluck(:ons_code)).to eq(["E07000041"]) + end + end + context "with case logs" do let(:other_organisation) { FactoryBot.create(:organisation) } let!(:owned_case_log) do From 80363d3c1987a98aaa52e8fd2ecbfc2634ce26a4 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Wed, 20 Apr 2022 18:06:13 +0100 Subject: [PATCH 02/20] Add spec fixture --- .../00013f30e159d7f72a3abe9ea93fb5b685d311e4.xml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 spec/fixtures/softwire_imports/organisation_la/00013f30e159d7f72a3abe9ea93fb5b685d311e4.xml diff --git a/spec/fixtures/softwire_imports/organisation_la/00013f30e159d7f72a3abe9ea93fb5b685d311e4.xml b/spec/fixtures/softwire_imports/organisation_la/00013f30e159d7f72a3abe9ea93fb5b685d311e4.xml new file mode 100644 index 000000000..e5c25f255 --- /dev/null +++ b/spec/fixtures/softwire_imports/organisation_la/00013f30e159d7f72a3abe9ea93fb5b685d311e4.xml @@ -0,0 +1,6 @@ + + + 44026acc7ed5c29516b26f2a5deb639e5e37966d + 7076 + E07000041 + From f8d16bf0987bfaea876d78efd5dd57c5ab37a543 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Wed, 20 Apr 2022 18:46:38 +0100 Subject: [PATCH 03/20] Import data --- app/models/organisation_la.rb | 1 + .../imports/organisation_la_import_service.rb | 23 +++++++++++ lib/tasks/data_import.rake | 2 + ...013f30e159d7f72a3abe9ea93fb5b685d311e4.xml | 0 .../organisation_la_import_service_spec.rb | 39 +++++++++++++++++++ 5 files changed, 65 insertions(+) create mode 100644 app/services/imports/organisation_la_import_service.rb rename spec/fixtures/softwire_imports/{organisation_la => organisation_las}/00013f30e159d7f72a3abe9ea93fb5b685d311e4.xml (100%) create mode 100644 spec/services/imports/organisation_la_import_service_spec.rb diff --git a/app/models/organisation_la.rb b/app/models/organisation_la.rb index 18ab26d26..452b65048 100644 --- a/app/models/organisation_la.rb +++ b/app/models/organisation_la.rb @@ -1,2 +1,3 @@ class OrganisationLa < ApplicationRecord + belongs_to :organisation end diff --git a/app/services/imports/organisation_la_import_service.rb b/app/services/imports/organisation_la_import_service.rb new file mode 100644 index 000000000..5d83b1aeb --- /dev/null +++ b/app/services/imports/organisation_la_import_service.rb @@ -0,0 +1,23 @@ +module Imports + class OrganisationLaImportService < ImportService + def create_organisation_las(folder) + import_from(folder, :create_organisation_la) + end + + private + + def create_organisation_la(xml_document) + xml_doc = xml_document.remove_namespaces! + organisation = Organisation.find_by(old_org_id: record_field_value(xml_document, "InstitutionId")) + + OrganisationLa.create!( + organisation:, + ons_code: record_field_value(xml_document, "ONSCode"), + ) + end + + def record_field_value(xml_document, field) + xml_document.at_xpath("//#{field}")&.text + end + end +end diff --git a/lib/tasks/data_import.rake b/lib/tasks/data_import.rake index b119b735d..daeaa7ab0 100644 --- a/lib/tasks/data_import.rake +++ b/lib/tasks/data_import.rake @@ -14,6 +14,8 @@ namespace :core do Imports::UserImportService.new(storage_service).create_users(path) when "data-protection-confirmation" Imports::DataProtectionConfirmationImportService.new(storage_service).create_data_protection_confirmations(path) + when "organisation_las" + Imports::OrganisationLaImportService.new(storage_service).create_organisation_la(path) else raise "Type #{type} is not supported by data_import" end diff --git a/spec/fixtures/softwire_imports/organisation_la/00013f30e159d7f72a3abe9ea93fb5b685d311e4.xml b/spec/fixtures/softwire_imports/organisation_las/00013f30e159d7f72a3abe9ea93fb5b685d311e4.xml similarity index 100% rename from spec/fixtures/softwire_imports/organisation_la/00013f30e159d7f72a3abe9ea93fb5b685d311e4.xml rename to spec/fixtures/softwire_imports/organisation_las/00013f30e159d7f72a3abe9ea93fb5b685d311e4.xml diff --git a/spec/services/imports/organisation_la_import_service_spec.rb b/spec/services/imports/organisation_la_import_service_spec.rb new file mode 100644 index 000000000..1dd20470c --- /dev/null +++ b/spec/services/imports/organisation_la_import_service_spec.rb @@ -0,0 +1,39 @@ +require "rails_helper" + +RSpec.describe Imports::OrganisationLaImportService do + let(:fixture_directory) { "spec/fixtures/softwire_imports/organisation_las" } + let(:old_org_id) { "44026acc7ed5c29516b26f2a5deb639e5e37966d" } + let(:old_id) { "00013f30e159d7f72a3abe9ea93fb5b685d311e4" } + let(:import_file) { File.open("#{fixture_directory}/#{old_id}.xml") } + let(:storage_service) { instance_double(StorageService) } + + context "when importing data protection confirmations" do + subject(:import_service) { described_class.new(storage_service) } + + before do + allow(storage_service) + .to receive(:list_files) + .and_return(["organisation_la_directory/#{old_id}.xml"]) + allow(storage_service) + .to receive(:get_file_io) + .with("organisation_la_directory/#{old_id}.xml") + .and_return(import_file) + end + + context "when the organisation in the import file doesn't exist in the system" do + it "does not create an organisation la record" do + expect { import_service.create_organisation_las("organisation_la_directory") } + .to raise_error(ActiveRecord::RecordInvalid, /Organisation must exist/) + end + end + + context "when the organisation does exist" do + let!(:organisation) { FactoryBot.create(:organisation, old_org_id:) } + + it "successfully create an organisation la record with the expected data" do + import_service.create_organisation_las("organisation_la_directory") + expect(Organisation.find_by(old_org_id:).organisation_las.pluck("ons_code")).to eq(["E07000041"]) + end + end + end +end From feefa4f358ce23d97be0b2caa2ab207f23a5b3f2 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Wed, 20 Apr 2022 18:51:08 +0100 Subject: [PATCH 04/20] Import task --- lib/tasks/data_import.rake | 4 ++-- spec/lib/tasks/data_import_spec.rb | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/tasks/data_import.rake b/lib/tasks/data_import.rake index daeaa7ab0..eb4554083 100644 --- a/lib/tasks/data_import.rake +++ b/lib/tasks/data_import.rake @@ -14,8 +14,8 @@ namespace :core do Imports::UserImportService.new(storage_service).create_users(path) when "data-protection-confirmation" Imports::DataProtectionConfirmationImportService.new(storage_service).create_data_protection_confirmations(path) - when "organisation_las" - Imports::OrganisationLaImportService.new(storage_service).create_organisation_la(path) + when "organisation-las" + Imports::OrganisationLaImportService.new(storage_service).create_organisation_las(path) else raise "Type #{type} is not supported by data_import" end diff --git a/spec/lib/tasks/data_import_spec.rb b/spec/lib/tasks/data_import_spec.rb index 0824aa622..eae18ff33 100644 --- a/spec/lib/tasks/data_import_spec.rb +++ b/spec/lib/tasks/data_import_spec.rb @@ -72,6 +72,24 @@ describe "rake core:data_import", type: :task do end end + context "when importing organisation local authority data" do + let(:type) { "organisation-las" } + let(:import_service) { instance_double(Imports::OrganisationLaImportService) } + let(:fixture_path) { "spec/fixtures/softwire_imports/organisation_las" } + + before do + allow(Imports::OrganisationLaImportService).to receive(:new).and_return(import_service) + end + + it "creates an organisation la from the given XML file" do + expect(StorageService).to receive(:new).with(paas_config_service, instance_name) + expect(Imports::OrganisationLaImportService).to receive(:new).with(storage_service) + expect(import_service).to receive(:create_organisation_las).with(fixture_path) + + task.invoke(type, fixture_path) + end + end + it "raises an exception if no parameters are provided" do expect { task.invoke }.to raise_error(/Usage/) end From 81d14d426b8985fef005e278cdbf884265f28b81 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 09:08:30 +0100 Subject: [PATCH 05/20] Refactor org edit permissions to helper --- app/helpers/user_helper.rb | 4 ++++ app/views/organisations/show.html.erb | 2 +- spec/helpers/user_helper_spec.rb | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb index 329920346..fc82b26cb 100644 --- a/app/helpers/user_helper.rb +++ b/app/helpers/user_helper.rb @@ -30,4 +30,8 @@ module UserHelper def can_edit_key_contact?(_user, current_user) current_user.data_coordinator? || current_user.support? end + + def can_edit_org?(current_user) + current_user.data_coordinator? || current_user.support? + end end diff --git a/app/views/organisations/show.html.erb b/app/views/organisations/show.html.erb index f98ea86a9..0cd186f2e 100644 --- a/app/views/organisations/show.html.erb +++ b/app/views/organisations/show.html.erb @@ -9,7 +9,7 @@ <%= govuk_summary_list do |summary_list| %> <% @organisation.display_attributes.each do |attr| %> - <% if current_user.data_coordinator? && attr[:editable] %> + <% if can_edit_org?(current_user) && attr[:editable] %> <%= summary_list.row do |row| %> <% row.key { attr[:name].to_s.humanize } %> <% row.value { simple_format(attr[:value].to_s, {}, wrapper_tag: "div") } %> diff --git a/spec/helpers/user_helper_spec.rb b/spec/helpers/user_helper_spec.rb index 5ec525c69..87d99f5ed 100644 --- a/spec/helpers/user_helper_spec.rb +++ b/spec/helpers/user_helper_spec.rb @@ -135,5 +135,29 @@ RSpec.describe UserHelper do end end end + + context "when the user is a data provider viewing organisation details" do + let(:current_user) { FactoryBot.create(:user, :data_provider) } + + it "does not allow changing details" do + expect(can_edit_org?(current_user)).to be false + end + end + + context "when the user is a data coordinator viewing organisation details" do + let(:current_user) { FactoryBot.create(:user, :data_coordinator) } + + it "does not allow changing details" do + expect(can_edit_org?(current_user)).to be true + end + end + + context "when the user is a support user viewing organisation details" do + let(:current_user) { FactoryBot.create(:user, :support) } + + it "does not allow changing details" do + expect(can_edit_org?(current_user)).to be true + end + end end end From c4e479281c46c8162b1956035fae2e0e88b4cc7c Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 09:08:47 +0100 Subject: [PATCH 06/20] Remove org la db field --- db/migrate/20220420165451_create_organisation_la.rb | 1 + db/schema.rb | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrate/20220420165451_create_organisation_la.rb b/db/migrate/20220420165451_create_organisation_la.rb index 52cacdfb2..435da3c68 100644 --- a/db/migrate/20220420165451_create_organisation_la.rb +++ b/db/migrate/20220420165451_create_organisation_la.rb @@ -6,5 +6,6 @@ class CreateOrganisationLa < ActiveRecord::Migration[7.0] t.timestamps end + remove_column :organisations, :local_authorities, :string end end diff --git a/db/schema.rb b/db/schema.rb index 451f16749..beff46c57 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 202202071123100) do +ActiveRecord::Schema[7.0].define(version: 2022_04_20_165451) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -271,7 +271,6 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do t.string "address_line1" t.string "address_line2" t.string "postcode" - t.string "local_authorities" t.boolean "holds_own_stock" t.string "other_stock_owners" t.string "managing_agents" From 5b4dc5a16cb5027d06c4c5294a3351d9073b4483 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 09:21:46 +0100 Subject: [PATCH 07/20] Format bullet lists --- app/helpers/details_table_helper.rb | 10 +++++++ app/models/organisation.rb | 6 ++++- app/views/organisations/show.html.erb | 4 +-- spec/helpers/table_details_helper_spec.rb | 32 +++++++++++++++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 app/helpers/details_table_helper.rb create mode 100644 spec/helpers/table_details_helper_spec.rb diff --git a/app/helpers/details_table_helper.rb b/app/helpers/details_table_helper.rb new file mode 100644 index 000000000..a3204c138 --- /dev/null +++ b/app/helpers/details_table_helper.rb @@ -0,0 +1,10 @@ +module DetailsTableHelper + def details_html(attribute) + if attribute[:format] == :bullet + list = attribute[:value].map { |la| "
  • #{la}
  • "}.join("\n") + simple_format(list, { class: "govuk-list govuk-list--bullet" }, wrapper_tag: "ul") + else + simple_format(attribute[:value].to_s, {}, wrapper_tag: "div") + end + end +end diff --git a/app/models/organisation.rb b/app/models/organisation.rb index bd8b77fdc..a5151be71 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -36,13 +36,17 @@ class Organisation < ApplicationRecord !!data_protection_confirmations.order(created_at: :desc).first&.confirmed end + def local_authorities + organisation_las.pluck(:ons_code) + end + def display_attributes [ { name: "name", value: name, editable: true }, { name: "address", value: address_string, editable: true }, { name: "telephone_number", value: phone, editable: true }, { name: "type", value: "Org type", editable: false }, - { name: "local_authorities_operated_in", value: local_authorities, editable: false }, + { name: "local_authorities_operated_in", value: local_authorities, editable: false, format: :bullet }, { name: "holds_own_stock", value: holds_own_stock.to_s.humanize, editable: false }, { name: "other_stock_owners", value: other_stock_owners, editable: false }, { name: "managing_agents", value: managing_agents, editable: false }, diff --git a/app/views/organisations/show.html.erb b/app/views/organisations/show.html.erb index 0cd186f2e..d59761d27 100644 --- a/app/views/organisations/show.html.erb +++ b/app/views/organisations/show.html.erb @@ -12,7 +12,7 @@ <% if can_edit_org?(current_user) && attr[:editable] %> <%= summary_list.row do |row| %> <% row.key { attr[:name].to_s.humanize } %> - <% row.value { simple_format(attr[:value].to_s, {}, wrapper_tag: "div") } %> + <% row.value { details_html(attr) } %> <% row.action( visually_hidden_text: "name", href: edit_organisation_path, @@ -22,7 +22,7 @@ <% else %> <%= summary_list.row do |row| %> <% row.key { attr[:name].to_s.humanize } %> - <% row.value { simple_format(attr[:value].to_s, {}, wrapper_tag: "div") } %> + <% row.value { details_html(attr) } %> <% row.action %> <% end %> <% end %> diff --git a/spec/helpers/table_details_helper_spec.rb b/spec/helpers/table_details_helper_spec.rb new file mode 100644 index 000000000..0b3470e5a --- /dev/null +++ b/spec/helpers/table_details_helper_spec.rb @@ -0,0 +1,32 @@ +require "rails_helper" + +RSpec.describe DetailsTableHelper do + + describe "details html" do + subject { details_html(attribute) } + + context "when given a simple attribute" do + let(:attribute) { { name: "name", value: "Dummy org", editable: true } } + + it "displays the string wrapped in a div" do + expect(subject).to eq("
    Dummy org
    ") + end + end + + context "when given a bullet point list of attibutes" do + let(:list) { ["Camden", "Westminster", "Bristol"] } + let(:attribute) do + { + name: "local_authorities_operated_in", + value: list, + editable: false, + format: :bullet, + } + end + + it "displays the string wrapped in an unordered list with the correct classes" do + expect(subject).to eq("
    • Camden
    • \n
    • Westminster
    • \n
    • Bristol
    ") + end + end + end +end From 2f73d250d1f0c85131e99ea5c8d6d365aaa1c2d4 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 09:26:56 +0100 Subject: [PATCH 08/20] Rubocop --- app/helpers/details_table_helper.rb | 2 +- .../imports/organisation_la_import_service.rb | 2 +- ...ls_helper_spec.rb => details_table_helper_spec.rb} | 11 +++++------ spec/models/organisation_spec.rb | 2 +- .../imports/organisation_la_import_service_spec.rb | 6 ++++-- 5 files changed, 12 insertions(+), 11 deletions(-) rename spec/helpers/{table_details_helper_spec.rb => details_table_helper_spec.rb} (75%) diff --git a/app/helpers/details_table_helper.rb b/app/helpers/details_table_helper.rb index a3204c138..5f489d963 100644 --- a/app/helpers/details_table_helper.rb +++ b/app/helpers/details_table_helper.rb @@ -1,7 +1,7 @@ module DetailsTableHelper def details_html(attribute) if attribute[:format] == :bullet - list = attribute[:value].map { |la| "
  • #{la}
  • "}.join("\n") + list = attribute[:value].map { |la| "
  • #{la}
  • " }.join("\n") simple_format(list, { class: "govuk-list govuk-list--bullet" }, wrapper_tag: "ul") else simple_format(attribute[:value].to_s, {}, wrapper_tag: "div") diff --git a/app/services/imports/organisation_la_import_service.rb b/app/services/imports/organisation_la_import_service.rb index 5d83b1aeb..4e6256a1a 100644 --- a/app/services/imports/organisation_la_import_service.rb +++ b/app/services/imports/organisation_la_import_service.rb @@ -7,7 +7,7 @@ module Imports private def create_organisation_la(xml_document) - xml_doc = xml_document.remove_namespaces! + xml_document.remove_namespaces! organisation = Organisation.find_by(old_org_id: record_field_value(xml_document, "InstitutionId")) OrganisationLa.create!( diff --git a/spec/helpers/table_details_helper_spec.rb b/spec/helpers/details_table_helper_spec.rb similarity index 75% rename from spec/helpers/table_details_helper_spec.rb rename to spec/helpers/details_table_helper_spec.rb index 0b3470e5a..202bace62 100644 --- a/spec/helpers/table_details_helper_spec.rb +++ b/spec/helpers/details_table_helper_spec.rb @@ -1,20 +1,19 @@ require "rails_helper" RSpec.describe DetailsTableHelper do - describe "details html" do - subject { details_html(attribute) } + let(:details) { details_html(attribute) } context "when given a simple attribute" do - let(:attribute) { { name: "name", value: "Dummy org", editable: true } } + let(:attribute) { { name: "name", value: "Dummy org", editable: true } } it "displays the string wrapped in a div" do - expect(subject).to eq("
    Dummy org
    ") + expect(details).to eq("
    Dummy org
    ") end end context "when given a bullet point list of attibutes" do - let(:list) { ["Camden", "Westminster", "Bristol"] } + let(:list) { %w[Camden Westminster Bristol] } let(:attribute) do { name: "local_authorities_operated_in", @@ -25,7 +24,7 @@ RSpec.describe DetailsTableHelper do end it "displays the string wrapped in an unordered list with the correct classes" do - expect(subject).to eq("
    • Camden
    • \n
    • Westminster
    • \n
    • Bristol
    ") + expect(details).to eq("
    • Camden
    • \n
    • Westminster
    • \n
    • Bristol
    ") end end end diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index d3c09368f..2c93414e3 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -35,7 +35,7 @@ RSpec.describe Organisation, type: :model do end it "has local authorities associated" do - expect(organisation.organisation_las.pluck(:ons_code)).to eq(["E07000041"]) + expect(organisation.organisation_las.pluck(:ons_code)).to eq(%w[E07000041]) end end diff --git a/spec/services/imports/organisation_la_import_service_spec.rb b/spec/services/imports/organisation_la_import_service_spec.rb index 1dd20470c..c0cf0cc4c 100644 --- a/spec/services/imports/organisation_la_import_service_spec.rb +++ b/spec/services/imports/organisation_la_import_service_spec.rb @@ -28,11 +28,13 @@ RSpec.describe Imports::OrganisationLaImportService do end context "when the organisation does exist" do - let!(:organisation) { FactoryBot.create(:organisation, old_org_id:) } + before do + FactoryBot.create(:organisation, old_org_id:) + end it "successfully create an organisation la record with the expected data" do import_service.create_organisation_las("organisation_la_directory") - expect(Organisation.find_by(old_org_id:).organisation_las.pluck("ons_code")).to eq(["E07000041"]) + expect(Organisation.find_by(old_org_id:).organisation_las.pluck("ons_code")).to eq(%w[E07000041]) end end end From d9883c13a465384dff383a51ca61ef7ff7fde5c2 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 11:22:22 +0100 Subject: [PATCH 09/20] Display LA name rather than code --- app/models/form.rb | 2 +- app/models/local_authority.rb | 5 +++++ app/models/organisation.rb | 8 ++++++-- spec/models/local_authority_spec.rb | 10 ++++++++++ spec/models/organisation_spec.rb | 8 ++++++-- 5 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 app/models/local_authority.rb create mode 100644 spec/models/local_authority_spec.rb diff --git a/app/models/form.rb b/app/models/form.rb index 3f1a83224..6beee8ec9 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -26,7 +26,7 @@ class Form def get_question(id, case_log) all_questions = questions.select { |q| q.id == id.to_s.underscore } - routed_question = all_questions.find { |q| q.page.routed_to?(case_log) } + routed_question = all_questions.find { |q| q.page.routed_to?(case_log) } if case_log routed_question || all_questions[0] end diff --git a/app/models/local_authority.rb b/app/models/local_authority.rb new file mode 100644 index 000000000..f0be218e4 --- /dev/null +++ b/app/models/local_authority.rb @@ -0,0 +1,5 @@ +class LocalAuthority + def self.ons_code_mappings + FormHandler.instance.forms["2021_2022"].get_question("la", nil).answer_options + end +end diff --git a/app/models/organisation.rb b/app/models/organisation.rb index a5151be71..85cf76028 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -37,7 +37,11 @@ class Organisation < ApplicationRecord end def local_authorities - organisation_las.pluck(:ons_code) + organisation_las.pluck(:ons_code).map { |ons_code| ons_code } + end + + def local_authority_names + local_authorities.map { |ons_code| LocalAuthority.ons_code_mappings[ons_code] } end def display_attributes @@ -46,7 +50,7 @@ class Organisation < ApplicationRecord { name: "address", value: address_string, editable: true }, { name: "telephone_number", value: phone, editable: true }, { name: "type", value: "Org type", editable: false }, - { name: "local_authorities_operated_in", value: local_authorities, editable: false, format: :bullet }, + { name: "local_authorities_operated_in", value: local_authority_names, editable: false, format: :bullet }, { name: "holds_own_stock", value: holds_own_stock.to_s.humanize, editable: false }, { name: "other_stock_owners", value: other_stock_owners, editable: false }, { name: "managing_agents", value: managing_agents, editable: false }, diff --git a/spec/models/local_authority_spec.rb b/spec/models/local_authority_spec.rb new file mode 100644 index 000000000..23c5c8447 --- /dev/null +++ b/spec/models/local_authority_spec.rb @@ -0,0 +1,10 @@ +require "rails_helper" + +RSpec.describe LocalAuthority, type: :model do + describe "ons code mapping" do + it "maps ONS code to local authority names" do + expect(described_class.ons_code_mappings).to be_a(Hash) + expect(described_class.ons_code_mappings["E07000178"]).to eq("Oxford") + end + end +end diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index 2c93414e3..a89ba1abf 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -31,11 +31,15 @@ RSpec.describe Organisation, type: :model do context "when the organisation only operates in specific local authorities" do before do - FactoryBot.create(:organisation_la, organisation_id: organisation.id) + FactoryBot.create(:organisation_la, organisation_id: organisation.id, ons_code: "E07000178") end it "has local authorities associated" do - expect(organisation.organisation_las.pluck(:ons_code)).to eq(%w[E07000041]) + expect(organisation.local_authorities).to eq(%w[E07000178]) + end + + it "maps the ons codes to LA names for display" do + expect(organisation.local_authority_names).to eq(%w[Oxford]) end end From d55a028719d79e7bb00e32c1efc75c4cc237a4b7 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 11:36:18 +0100 Subject: [PATCH 10/20] Have form handler class decide the current form --- app/models/form_handler.rb | 4 ++++ app/models/local_authority.rb | 2 +- spec/models/form_handler_spec.rb | 9 +++++++++ spec/models/local_authority_spec.rb | 5 +++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/models/form_handler.rb b/app/models/form_handler.rb index 8228077ca..dfb2b7266 100644 --- a/app/models/form_handler.rb +++ b/app/models/form_handler.rb @@ -10,6 +10,10 @@ class FormHandler @forms[form] end + def current_form + forms[forms.keys.sort { |a, b| a.to_i <=> b.to_i }.last] + end + private def get_all_forms diff --git a/app/models/local_authority.rb b/app/models/local_authority.rb index f0be218e4..bced9a41f 100644 --- a/app/models/local_authority.rb +++ b/app/models/local_authority.rb @@ -1,5 +1,5 @@ class LocalAuthority def self.ons_code_mappings - FormHandler.instance.forms["2021_2022"].get_question("la", nil).answer_options + FormHandler.instance.current_form.get_question("la", nil).answer_options end end diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb index 4accfa6c5..fb793d210 100644 --- a/spec/models/form_handler_spec.rb +++ b/spec/models/form_handler_spec.rb @@ -21,6 +21,15 @@ RSpec.describe FormHandler do end end + describe "Current form" do + it "returns the latest form by date" do + form_handler = described_class.instance + form = form_handler.current_form + expect(form).to be_a(Form) + expect(form.start_date.year).to eq(2022) + end + end + it "loads the form once at boot time" do form_handler = described_class.instance expect(Form).not_to receive(:new).with(:any, test_form_name) diff --git a/spec/models/local_authority_spec.rb b/spec/models/local_authority_spec.rb index 23c5c8447..a2bceb751 100644 --- a/spec/models/local_authority_spec.rb +++ b/spec/models/local_authority_spec.rb @@ -2,6 +2,11 @@ require "rails_helper" RSpec.describe LocalAuthority, type: :model do describe "ons code mapping" do + let(:form) { Form.new("spec/fixtures/forms/2021_2022.json", "2021_2022") } + before do + allow(FormHandler.instance).to receive(:current_form).and_return(form) + end + it "maps ONS code to local authority names" do expect(described_class.ons_code_mappings).to be_a(Hash) expect(described_class.ons_code_mappings["E07000178"]).to eq("Oxford") From 6f6496ceaaa154a2cbe74b2b3afe566c770d5f62 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 11:48:39 +0100 Subject: [PATCH 11/20] Unit test --- app/models/form_handler.rb | 2 +- spec/models/local_authority_spec.rb | 1 + spec/models/organisation_spec.rb | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/models/form_handler.rb b/app/models/form_handler.rb index dfb2b7266..c74a75db3 100644 --- a/app/models/form_handler.rb +++ b/app/models/form_handler.rb @@ -11,7 +11,7 @@ class FormHandler end def current_form - forms[forms.keys.sort { |a, b| a.to_i <=> b.to_i }.last] + forms[forms.keys.max_by(&:to_i)] end private diff --git a/spec/models/local_authority_spec.rb b/spec/models/local_authority_spec.rb index a2bceb751..34990f296 100644 --- a/spec/models/local_authority_spec.rb +++ b/spec/models/local_authority_spec.rb @@ -3,6 +3,7 @@ require "rails_helper" RSpec.describe LocalAuthority, type: :model do describe "ons code mapping" do let(:form) { Form.new("spec/fixtures/forms/2021_2022.json", "2021_2022") } + before do allow(FormHandler.instance).to receive(:current_form).and_return(form) end diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index a89ba1abf..8039a5272 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -30,8 +30,22 @@ RSpec.describe Organisation, type: :model do end context "when the organisation only operates in specific local authorities" do + let(:ons_code_mappings) do + { + "" => "Select an option", + "E07000223" => "Adur", + "E09000023" => "Lewisham", + "E08000003" => "Manchester", + "E07000178" => "Oxford", + "E07000114" => "Thanet", + "E09000033" => "Westminster", + "E06000014" => "York" + } + end + before do FactoryBot.create(:organisation_la, organisation_id: organisation.id, ons_code: "E07000178") + allow(LocalAuthority).to receive(:ons_code_mappings).and_return(ons_code_mappings) end it "has local authorities associated" do From 809667c67350a06d3fb371c41ee0e74134690a2f Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 11:55:36 +0100 Subject: [PATCH 12/20] Rubocop --- spec/models/organisation_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index 8039a5272..4766c35fa 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -39,7 +39,7 @@ RSpec.describe Organisation, type: :model do "E07000178" => "Oxford", "E07000114" => "Thanet", "E09000033" => "Westminster", - "E06000014" => "York" + "E06000014" => "York", } end From f4d26cd172bb63010dcedbbb3dcf2cbc07aeef6d Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 11:57:46 +0100 Subject: [PATCH 13/20] Remove removed field from seed file --- db/seeds.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/db/seeds.rb b/db/seeds.rb index 0e63f2e5a..2ee176d38 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -11,7 +11,6 @@ org = Organisation.create!( address_line1: "2 Marsham Street", address_line2: "London", postcode: "SW1P 4DF", - local_authorities: "None", holds_own_stock: false, other_stock_owners: "None", managing_agents: "None", From d9338984f5848062c2efeda9e9a2bb7565c18903 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 13:01:44 +0100 Subject: [PATCH 14/20] Don't block support users from org details page --- app/controllers/organisations_controller.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 36818db4b..25c75146f 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -51,8 +51,6 @@ private end def find_resource - return if current_user.support? - @organisation = Organisation.find(params[:id]) end end From bd0ce09917e77661da5669157eb0704cc258c74d Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 13:03:51 +0100 Subject: [PATCH 15/20] Remove unnecessary line break --- app/helpers/details_table_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/details_table_helper.rb b/app/helpers/details_table_helper.rb index 5f489d963..db569102d 100644 --- a/app/helpers/details_table_helper.rb +++ b/app/helpers/details_table_helper.rb @@ -1,7 +1,7 @@ module DetailsTableHelper def details_html(attribute) if attribute[:format] == :bullet - list = attribute[:value].map { |la| "
  • #{la}
  • " }.join("\n") + list = attribute[:value].map { |la| "
  • #{la}
  • " }.join simple_format(list, { class: "govuk-list govuk-list--bullet" }, wrapper_tag: "ul") else simple_format(attribute[:value].to_s, {}, wrapper_tag: "div") From 829e19947807ff819dab369ff9ead9f7190f235f Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 13:14:19 +0100 Subject: [PATCH 16/20] Move LA validation to LA validation file --- .../local_authority_validations.rb | 46 +++++++++++++++++++ .../validations/property_validations.rb | 46 ------------------- spec/helpers/details_table_helper_spec.rb | 2 +- .../local_authority_validations_spec.rb | 43 +++++++++++++++++ .../validations/property_validations_spec.rb | 43 ----------------- 5 files changed, 90 insertions(+), 90 deletions(-) diff --git a/app/models/validations/local_authority_validations.rb b/app/models/validations/local_authority_validations.rb index a7b3ed30d..72846f4e8 100644 --- a/app/models/validations/local_authority_validations.rb +++ b/app/models/validations/local_authority_validations.rb @@ -8,4 +8,50 @@ module Validations::LocalAuthorityValidations record.errors.add :ppostcode_full, error_message end end + + LONDON_BOROUGHS = %w[E09000001 + E09000002 + E09000003 + E09000004 + E09000005 + E09000006 + E09000007 + E09000008 + E09000009 + E09000010 + E09000011 + E09000012 + E09000013 + E09000014 + E09000015 + E09000016 + E09000017 + E09000018 + E09000019 + E09000020 + E09000021 + E09000022 + E09000023 + E09000024 + E09000025 + E09000026 + E09000027 + E09000028 + E09000029 + E09000030 + E09000031 + E09000032 + E09000033].freeze + def validate_la(record) + if record.la.present? && !LONDON_BOROUGHS.include?(record.la) && record.is_london_rent? + record.errors.add :la, I18n.t("validations.property.la.london_rent") + if record.postcode_known? && record.postcode_full.present? + record.errors.add :postcode_full, I18n.t("validations.property.la.london_rent_postcode") + end + end + + if record.la_known? && record.la.blank? + record.errors.add :la, I18n.t("validations.property.la.la_known") + end + end end diff --git a/app/models/validations/property_validations.rb b/app/models/validations/property_validations.rb index 720cad20d..050cdbd37 100644 --- a/app/models/validations/property_validations.rb +++ b/app/models/validations/property_validations.rb @@ -21,52 +21,6 @@ module Validations::PropertyValidations end end - LONDON_BOROUGHS = %w[E09000001 - E09000002 - E09000003 - E09000004 - E09000005 - E09000006 - E09000007 - E09000008 - E09000009 - E09000010 - E09000011 - E09000012 - E09000013 - E09000014 - E09000015 - E09000016 - E09000017 - E09000018 - E09000019 - E09000020 - E09000021 - E09000022 - E09000023 - E09000024 - E09000025 - E09000026 - E09000027 - E09000028 - E09000029 - E09000030 - E09000031 - E09000032 - E09000033].freeze - def validate_la(record) - if record.la.present? && !LONDON_BOROUGHS.include?(record.la) && record.is_london_rent? - record.errors.add :la, I18n.t("validations.property.la.london_rent") - if record.postcode_known? && record.postcode_full.present? - record.errors.add :postcode_full, I18n.t("validations.property.la.london_rent_postcode") - end - end - - if record.la_known? && record.la.blank? - record.errors.add :la, I18n.t("validations.property.la.la_known") - end - end - REFERRAL_INVALID_TMP = [8, 10, 12, 13, 14, 15].freeze def validate_rsnvac(record) if !record.first_time_property_let_as_social_housing? && record.has_first_let_vacancy_reason? diff --git a/spec/helpers/details_table_helper_spec.rb b/spec/helpers/details_table_helper_spec.rb index 202bace62..f0df11c14 100644 --- a/spec/helpers/details_table_helper_spec.rb +++ b/spec/helpers/details_table_helper_spec.rb @@ -24,7 +24,7 @@ RSpec.describe DetailsTableHelper do end it "displays the string wrapped in an unordered list with the correct classes" do - expect(details).to eq("
    • Camden
    • \n
    • Westminster
    • \n
    • Bristol
    ") + expect(details).to eq("
    • Camden
    • Westminster
    • Bristol
    ") end end end diff --git a/spec/models/validations/local_authority_validations_spec.rb b/spec/models/validations/local_authority_validations_spec.rb index 6ece1932c..a2394f49d 100644 --- a/spec/models/validations/local_authority_validations_spec.rb +++ b/spec/models/validations/local_authority_validations_spec.rb @@ -35,4 +35,47 @@ RSpec.describe Validations::LocalAuthorityValidations do expect(record.errors["ppostcode_full"]).to include(match I18n.t("validations.postcode")) end end + + describe "#validate_la" do + context "when the rent type is London affordable" do + let(:expected_error) { I18n.t("validations.property.la.london_rent") } + + it "validates that the local authority is in London" do + record.la = "E07000105" + record.rent_type = 2 + local_auth_validator.validate_la(record) + expect(record.errors["la"]).to include(match(expected_error)) + expect(record.errors["postcode_full"]).to be_empty + end + + it "expects that the local authority is in London" do + record.la = "E09000033" + record.rent_type = 2 + local_auth_validator.validate_la(record) + expect(record.errors["la"]).to be_empty + end + + context "when the la has been derived from a known postcode" do + let(:expected_error) { I18n.t("validations.property.la.london_rent_postcode") } + + it "also adds an error to the postcode field" do + record.la = "E07000105" + record.rent_type = 2 + record.postcode_known = 1 + record.postcode_full = "BN18 7TR" + local_auth_validator.validate_la(record) + expect(record.errors["postcode_full"]).to include(match(expected_error)) + end + end + end + + context "when previous la is known" do + it "la has to be provided" do + record.la_known = 1 + local_auth_validator.validate_la(record) + expect(record.errors["la"]) + .to include(match I18n.t("validations.property.la.la_known")) + end + end + end end diff --git a/spec/models/validations/property_validations_spec.rb b/spec/models/validations/property_validations_spec.rb index 08052ee7e..5d8b6f51e 100644 --- a/spec/models/validations/property_validations_spec.rb +++ b/spec/models/validations/property_validations_spec.rb @@ -147,49 +147,6 @@ RSpec.describe Validations::PropertyValidations do end end - describe "#validate_la" do - context "when the rent type is London affordable" do - let(:expected_error) { I18n.t("validations.property.la.london_rent") } - - it "validates that the local authority is in London" do - record.la = "E07000105" - record.rent_type = 2 - property_validator.validate_la(record) - expect(record.errors["la"]).to include(match(expected_error)) - expect(record.errors["postcode_full"]).to be_empty - end - - it "expects that the local authority is in London" do - record.la = "E09000033" - record.rent_type = 2 - property_validator.validate_la(record) - expect(record.errors["la"]).to be_empty - end - - context "when the la has been derived from a known postcode" do - let(:expected_error) { I18n.t("validations.property.la.london_rent_postcode") } - - it "also adds an error to the postcode field" do - record.la = "E07000105" - record.rent_type = 2 - record.postcode_known = 1 - record.postcode_full = "BN18 7TR" - property_validator.validate_la(record) - expect(record.errors["postcode_full"]).to include(match(expected_error)) - end - end - end - - context "when previous la is known" do - it "la has to be provided" do - record.la_known = 1 - property_validator.validate_la(record) - expect(record.errors["la"]) - .to include(match I18n.t("validations.property.la.la_known")) - end - end - end - describe "#validate_unitletas" do context "when the property has not been let before" do it "validates that no previous let type is provided" do From 4ef43c87382f627bfa147bdb5937922050ab6895 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 13:35:08 +0100 Subject: [PATCH 17/20] Add validation --- .../local_authority_validations.rb | 32 ++++++++++------- config/locales/en.yml | 1 + .../local_authority_validations_spec.rb | 35 +++++++++++++++++++ 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/app/models/validations/local_authority_validations.rb b/app/models/validations/local_authority_validations.rb index 72846f4e8..94f02a745 100644 --- a/app/models/validations/local_authority_validations.rb +++ b/app/models/validations/local_authority_validations.rb @@ -9,6 +9,26 @@ module Validations::LocalAuthorityValidations end end + def validate_la(record) + if record.la.present? && !LONDON_BOROUGHS.include?(record.la) && record.is_london_rent? + record.errors.add :la, I18n.t("validations.property.la.london_rent") + if record.postcode_known? && record.postcode_full.present? + record.errors.add :postcode_full, I18n.t("validations.property.la.london_rent_postcode") + end + end + + if record.la_known? && record.la.blank? + record.errors.add :la, I18n.t("validations.property.la.la_known") + end + + if record.owning_organisation && record.owning_organisation.local_authorities.present? && + record.la && !record.owning_organisation.local_authorities.include?(record.la) + la_name = record.form.get_question("la", record).label_from_value(record.la) + org_name = record.owning_organisation.name + record.errors.add :la, I18n.t("validations.property.la.la_invalid_for_org", org_name:, la_name:) + end + end + LONDON_BOROUGHS = %w[E09000001 E09000002 E09000003 @@ -42,16 +62,4 @@ module Validations::LocalAuthorityValidations E09000031 E09000032 E09000033].freeze - def validate_la(record) - if record.la.present? && !LONDON_BOROUGHS.include?(record.la) && record.is_london_rent? - record.errors.add :la, I18n.t("validations.property.la.london_rent") - if record.postcode_known? && record.postcode_full.present? - record.errors.add :postcode_full, I18n.t("validations.property.la.london_rent_postcode") - end - end - - if record.la_known? && record.la.blank? - record.errors.add :la, I18n.t("validations.property.la.la_known") - end - end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 076f547bf..2d66ac916 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -70,6 +70,7 @@ en: london_rent: "Local authority must be in London" london_rent_postcode: "The postcode must be a London postcode because you told us the rent type is London Affordable Rent or London Living Rent" la_known: "Enter name of local authority" + la_invalid_for_org: "%{org_name} does not operate in %{la_name}" rsnvac: first_let_not_social: "Reason for vacancy cannot be first let if unit has been previously let as social housing" first_let_social: "Reason for vacancy must be first let if unit has been previously let as social housing" diff --git a/spec/models/validations/local_authority_validations_spec.rb b/spec/models/validations/local_authority_validations_spec.rb index a2394f49d..ddd3afe8f 100644 --- a/spec/models/validations/local_authority_validations_spec.rb +++ b/spec/models/validations/local_authority_validations_spec.rb @@ -77,5 +77,40 @@ RSpec.describe Validations::LocalAuthorityValidations do .to include(match I18n.t("validations.property.la.la_known")) end end + + context "when the organisation only operates in specific local authorities" do + let(:organisation) { FactoryBot.create(:organisation) } + let(:record) { FactoryBot.create(:case_log, owning_organisation: organisation) } + + before do + FactoryBot.create(:organisation_la, organisation:, ons_code: "E07000178") + FactoryBot.create(:organisation_la, organisation:, ons_code: "E09000033") + end + + it "validates that the local authority is one the owning organisation operates in" do + record.la = "E06000014" + local_auth_validator.validate_la(record) + expect(record.errors["la"]) + .to include(match I18n.t( + "validations.property.la.la_invalid_for_org", + org_name: organisation.name, + la_name: "York", + )) + end + + it "expects that the local authority can be one that the owning organisation operates in" do + record.la = "E07000178" + local_auth_validator.validate_la(record) + expect(record.errors["la"]).to be_empty + end + end + + context "when the organisation has not listed specific local authorities it operates in" do + it "does not validate the local authority for the organisation" do + record.la = "E06000014" + local_auth_validator.validate_la(record) + expect(record.errors["la"]).to be_empty + end + end end end From 6f985f3b1d81b70a18b3fc4d566cc1301ca5347c Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 13:43:38 +0100 Subject: [PATCH 18/20] Indentation --- app/models/validations/local_authority_validations.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/validations/local_authority_validations.rb b/app/models/validations/local_authority_validations.rb index 94f02a745..23ac8c590 100644 --- a/app/models/validations/local_authority_validations.rb +++ b/app/models/validations/local_authority_validations.rb @@ -22,10 +22,10 @@ module Validations::LocalAuthorityValidations end if record.owning_organisation && record.owning_organisation.local_authorities.present? && - record.la && !record.owning_organisation.local_authorities.include?(record.la) - la_name = record.form.get_question("la", record).label_from_value(record.la) - org_name = record.owning_organisation.name - record.errors.add :la, I18n.t("validations.property.la.la_invalid_for_org", org_name:, la_name:) + record.la && !record.owning_organisation.local_authorities.include?(record.la) + la_name = record.form.get_question("la", record).label_from_value(record.la) + org_name = record.owning_organisation.name + record.errors.add :la, I18n.t("validations.property.la.la_invalid_for_org", org_name:, la_name:) end end From 134b6d2ae7432b538c40aa9a611bcf2b64127180 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 15:51:07 +0100 Subject: [PATCH 19/20] Bump Dependencies --- Gemfile.lock | 2 +- yarn.lock | 125 ++++++++++++++++++++++++++++----------------------- 2 files changed, 71 insertions(+), 56 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 098243ed8..6c6971c92 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,7 +12,7 @@ GIT GIT remote: https://github.com/baarkerlounger/two_factor_authentication.git - revision: afb91d5ffabbdb79ca29645749ef625f7e3a76ea + revision: 5fa6ba40d90df9c1711d1b5eeff34686dda133a2 specs: two_factor_authentication (2.2.0) devise diff --git a/yarn.lock b/yarn.lock index 8d92060ac..2f44d7947 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3,9 +3,9 @@ "@activeadmin/activeadmin@^2.11.0": - version "2.11.1" - resolved "https://registry.yarnpkg.com/@activeadmin/activeadmin/-/activeadmin-2.11.1.tgz#efddb266f9cc88fa6a9c7fbe87558cb7874998a0" - integrity sha512-YZ3IhxVcg3BaxojAuiy6fhhzH6xDGWw4TRvLf5lMiWaPGwABjC0G4q9dgf6vdZGCNL2Y3LFqQC4xin2EL9lrQQ== + version "2.11.2" + resolved "https://registry.yarnpkg.com/@activeadmin/activeadmin/-/activeadmin-2.11.2.tgz#092f07042e910323a584cbd146d03c45502c72b4" + integrity sha512-d6zGSCvHejIyLR6yF5elw62CcECNnbhl0Gd6pI7dzO5IGz4JMXZEPBpkKUztnqvDbye4tFbSWnTaKC3ZGH7x9A== dependencies: jquery "^3.4.1" jquery-ui "^1.12.1" @@ -929,9 +929,9 @@ integrity sha512-Fg32GrJo61m+VqYSdRSjRXMjQ06j8YIYfcTqndLYVAaHmroZHLJZCydsWBOTDqXS2v+mjxohBWEMfg97GXmYQg== "@jridgewell/trace-mapping@^0.3.0": - version "0.3.4" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.4.tgz#f6a0832dffd5b8a6aaa633b7d9f8e8e94c83a0c3" - integrity sha512-vFv9ttIedivx0ux3QSjhgtCVjPZd5l46ZOMDSCwnH1yUO2e964gO8LZGyv2QkqcgR6TnBU1v+1IFqmeoG+0UJQ== + version "0.3.9" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" + integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== dependencies: "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" @@ -994,9 +994,9 @@ integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== "@types/node@*": - version "17.0.23" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.23.tgz#3b41a6e643589ac6442bdbd7a4a3ded62f33f7da" - integrity sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw== + version "17.0.25" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.25.tgz#527051f3c2f77aa52e5dc74e45a3da5fb2301448" + integrity sha512-wANk6fBrUwdpY4isjWrKTufkrXdu1D2YHCot2fD/DfWxF5sMrVSA+KN7ydckvaTCh0HiqX9IVl0L5/ZoXg5M7w== "@types/parse-json@^4.0.0": version "4.0.0" @@ -1258,9 +1258,9 @@ array-union@^3.0.1: integrity sha512-1OvF9IbWwaeiM9VhzYXVQacMibxpXOMYVNIvMtKRyX9SImBXpKcFr8XvFDeEslCyuH/t6KRt7HEO94AlP8Iatw== babel-loader@^8.2.3: - version "8.2.4" - resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.2.4.tgz#95f5023c791b2e9e2ca6f67b0984f39c82ff384b" - integrity sha512-8dytA3gcvPPPv4Grjhnt8b5IIiTcq/zeXOPk4iTYI0SVXcsmuGg7JtBRDp8S9X+gJfhQ8ektjXZlDu1Bb33U8A== + version "8.2.5" + resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.2.5.tgz#d45f585e654d5a5d90f5350a779d7647c5ed512e" + integrity sha512-OSiFfH89LrEMiWd4pLNqGz4CwJDtbs2ZVc+iGu2HrkRfPxId9F2anQj38IxWpmRfsUY0aBZYi1EFcd3mhtRMLQ== dependencies: find-cache-dir "^3.3.1" loader-utils "^2.0.0" @@ -1324,7 +1324,7 @@ braces@^3.0.2, braces@~3.0.2: dependencies: fill-range "^7.0.1" -browserslist@^4.14.5, browserslist@^4.17.5, browserslist@^4.19.1: +browserslist@^4.14.5, browserslist@^4.17.5, browserslist@^4.20.2: version "4.20.2" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.2.tgz#567b41508757ecd904dab4d1c646c612cd3d4f88" integrity sha512-CQOBCqp/9pDvDbx3xfMi+86pr4KXIf2FDkTTdeuYw8OxS9t898LA1Khq57gtufFILXpfgsSx5woNgsBgvGjpsA== @@ -1354,9 +1354,9 @@ callsites@^3.0.0: integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== caniuse-lite@^1.0.30001317: - version "1.0.30001328" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001328.tgz#0ed7a2ca65ec45872c613630201644237ba1e329" - integrity sha512-Ue55jHkR/s4r00FLNiX+hGMMuwml/QGqqzVeMQ5thUewznU2EdULFvI3JR7JJid6OrjJNfFvHY2G2dIjmRaDDQ== + version "1.0.30001332" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001332.tgz#39476d3aa8d83ea76359c70302eafdd4a1d727dd" + integrity sha512-10T30NYOEQtN6C11YGg411yebhvpnC6Z102+B95eAsN0oB6KUs01ivE8u+G6FMIRtIrVlYXhL+LUwQ3/hXwDWw== chalk@^2.0.0: version "2.4.2" @@ -1467,17 +1467,17 @@ copy-webpack-plugin@^10.2.4: serialize-javascript "^6.0.0" core-js-compat@^3.20.2, core-js-compat@^3.21.0: - version "3.21.1" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.21.1.tgz#cac369f67c8d134ff8f9bd1623e3bc2c42068c82" - integrity sha512-gbgX5AUvMb8gwxC7FLVWYT7Kkgu/y7+h/h1X43yJkNqhlK2fuYyQimqvKGNZFAY6CKii/GFKJ2cp/1/42TN36g== + version "3.22.2" + resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.22.2.tgz#eec621eb276518efcf718d0a6d9d042c3d0cad48" + integrity sha512-Fns9lU06ZJ07pdfmPMu7OnkIKGPKDzXKIiuGlSvHHapwqMUF2QnnsWwtueFZtSyZEilP0o6iUeHQwpn7LxtLUw== dependencies: - browserslist "^4.19.1" + browserslist "^4.20.2" semver "7.0.0" core-js@^3.21.1, core-js@^3.4.0: - version "3.21.1" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.21.1.tgz#f2e0ddc1fc43da6f904706e8e955bc19d06a0d94" - integrity sha512-FRq5b/VMrWlrmCzwRrpDYNxyHP9BcAZC+xHJaqTgIE5091ZV1NTmyh0sGOg5XqpnHvR0svdy0sv1gWA1zmhxig== + version "3.22.2" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.22.2.tgz#3ea0a245b0895fa39d1faa15fe75d91ade504a01" + integrity sha512-Z5I2vzDnEIqO2YhELVMFcL1An2CIsFe9Q7byZhs8c/QxummxZlAHw33TUHbIte987LkisOgL0LwQ1P9D6VISnA== cosmiconfig@^7.0.0: version "7.0.1" @@ -1536,11 +1536,12 @@ debug@^4.1.0, debug@^4.1.1: ms "2.1.2" define-properties@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" - integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== + version "1.1.4" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.4.tgz#0b14d7bd7fbeb2f3572c3a7eda80ea5d57fb05b1" + integrity sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA== dependencies: - object-keys "^1.0.12" + has-property-descriptors "^1.0.0" + object-keys "^1.1.1" dir-glob@^3.0.1: version "3.0.1" @@ -1550,9 +1551,9 @@ dir-glob@^3.0.1: path-type "^4.0.0" electron-to-chromium@^1.4.84: - version "1.4.107" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.107.tgz#564257014ab14033b4403a309c813123c58a3fb9" - integrity sha512-Huen6taaVrUrSy8o7mGStByba8PfOWWluHNxSHGBrCgEdFVLtvdQDBr9LBCF9Uci8SYxh28QNNMO0oC17wbGAg== + version "1.4.117" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.117.tgz#829d747deb9faa653cab72764a891ef523ba7413" + integrity sha512-ypZHxY+Sf/PXu7LVN+xoeanyisnJeSOy8Ki439L/oLueZb4c72FI45zXcK3gPpmTwyufh9m6NnbMLXnJh/0Fxg== element-closest@^2.0.2: version "2.0.2" @@ -1565,9 +1566,9 @@ emojis-list@^3.0.0: integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== enhanced-resolve@^5.9.2: - version "5.9.2" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.9.2.tgz#0224dcd6a43389ebfb2d55efee517e5466772dd9" - integrity sha512-GIm3fQfwLJ8YZx2smuHpBKkXC1yOk+OBEmKckVyL0i/ea8mqDEykK3ld5dgH1QYPNyT/lIllxV2LULnxCHaHkA== + version "5.9.3" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.9.3.tgz#44a342c012cbc473254af5cc6ae20ebd0aae5d88" + integrity sha512-Bq9VSor+kjvW3f9/MiiR4eE3XYgOl7/rS8lnSxbRbF3kS0B2r+Y9w5krBWxZgDxASVZbdYrn5wT4j/Wb0J9qow== dependencies: graceful-fs "^4.2.4" tapable "^2.2.0" @@ -1734,7 +1735,7 @@ gensync@^1.0.0-beta.2: resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== -get-intrinsic@^1.0.2: +get-intrinsic@^1.0.2, get-intrinsic@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== @@ -1804,6 +1805,13 @@ has-flag@^4.0.0: resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== +has-property-descriptors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz#610708600606d36961ed04c196193b6a607fa861" + integrity sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ== + dependencies: + get-intrinsic "^1.1.1" + has-symbols@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" @@ -1880,9 +1888,9 @@ is-binary-path@~2.1.0: binary-extensions "^2.0.0" is-core-module@^2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211" - integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA== + version "2.9.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.9.0.tgz#e1c34429cd51c6dd9e09e0799e396e27b19a9c69" + integrity sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A== dependencies: has "^1.0.3" @@ -2007,9 +2015,9 @@ lines-and-columns@^1.1.6: integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== loader-runner@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.2.0.tgz#d7022380d66d14c5fb1d496b89864ebcfd478384" - integrity sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw== + version "4.3.0" + resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1" + integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg== loader-utils@^2.0.0: version "2.0.2" @@ -2032,10 +2040,12 @@ lodash.debounce@^4.0.8: resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168= -lru-cache@^7.4.0: - version "7.8.1" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.8.1.tgz#68ee3f4807a57d2ba185b7fd90827d5c21ce82bb" - integrity sha512-E1v547OCgJvbvevfjgK9sNKIVXO96NnsTsFPBlg4ZxjhsJSODoH9lk8Bm0OxvHNm6Vm5Yqkl/1fErDxhYL8Skg== +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" make-dir@^3.0.2, make-dir@^3.1.0: version "3.1.0" @@ -2097,9 +2107,9 @@ mutation-observer-inner-html-shim@^1.0.0: integrity sha512-YmJPDSUWJgBhwqRJP6AMvjdfDHU1gsrT5YdgpxMit2+x1khLYhdYq9fvp4clPsYecVT3JOprBf/KjEX7IqlU+g== nanoid@^3.3.1: - version "3.3.2" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.2.tgz#c89622fafb4381cd221421c69ec58547a1eec557" - integrity sha512-CuHBogktKwpm5g2sRgv83jEy2ijFzBwMoYA60orPDR7ynsLijJDqgsi4RDGj3OJpy3Ieb+LYwiRmIOGyytgITA== + version "3.3.3" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.3.tgz#fd8e8b7aa761fe807dba2d1b98fb7241bb724a25" + integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w== neo-async@^2.6.2: version "2.6.2" @@ -2123,7 +2133,7 @@ npm-run-path@^4.0.1: dependencies: path-key "^3.0.0" -object-keys@^1.0.12, object-keys@^1.1.1: +object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== @@ -2414,9 +2424,9 @@ sass-loader@^12.6.0: neo-async "^2.6.2" sass@^1.49.9: - version "1.50.0" - resolved "https://registry.yarnpkg.com/sass/-/sass-1.50.0.tgz#3e407e2ebc53b12f1e35ce45efb226ea6063c7c8" - integrity sha512-cLsD6MEZ5URXHStxApajEh7gW189kkjn4Rc8DQweMyF+o5HF5nfEz8QYLMlPsTOD88DknatTmBWkOcw5/LnJLQ== + version "1.50.1" + resolved "https://registry.yarnpkg.com/sass/-/sass-1.50.1.tgz#e9b078a1748863013c4712d2466ce8ca4e4ed292" + integrity sha512-noTnY41KnlW2A9P8sdwESpDmo+KBNkukI1i8+hOK3footBUcohNHtdOJbckp46XO95nuvcHDDZ+4tmOnpK3hjw== dependencies: chokidar ">=3.0.0 <4.0.0" immutable "^4.0.0" @@ -2461,11 +2471,11 @@ semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0: integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== semver@^7.3.5: - version "7.3.6" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.6.tgz#5d73886fb9c0c6602e79440b97165c29581cbb2b" - integrity sha512-HZWqcgwLsjaX1HBD31msI/rXktuIhS+lWvdE4kN9z+8IVT4Itc7vqU2WvYsyD6/sjYCt4dEKH/m1M3dwI9CC5w== + version "7.3.7" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f" + integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== dependencies: - lru-cache "^7.4.0" + lru-cache "^6.0.0" serialize-javascript@^6.0.0: version "6.0.0" @@ -2721,6 +2731,11 @@ wildcard@^2.0.0: resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.0.tgz#a77d20e5200c6faaac979e4b3aadc7b3dd7f8fec" integrity sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw== +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + yaml@^1.10.0: version "1.10.2" resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" From fa5dd55c65d6b900037f0868c4863e934df70991 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 16:45:12 +0100 Subject: [PATCH 20/20] Fix erb lint regressions --- app/views/users/edit.html.erb | 2 +- app/views/users/new.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index d357f69fc..6cbfea0e1 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -25,7 +25,7 @@ spellcheck: "false" %> <% if current_user.data_coordinator? || current_user.support? %> - <%= roles = current_user.assignable_roles.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> + <% roles = current_user.assignable_roles.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <%= f.govuk_collection_radio_buttons :role, roles, diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 488290ee2..c1bdee263 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -25,7 +25,7 @@ spellcheck: "false", value: @resource.email %> - <%= roles = current_user.assignable_roles.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> + <% roles = current_user.assignable_roles.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <%= f.govuk_collection_radio_buttons :role, roles,