From 2f73d250d1f0c85131e99ea5c8d6d365aaa1c2d4 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 21 Apr 2022 09:26:56 +0100 Subject: [PATCH] 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("") + expect(details).to eq("") 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