Browse Source

Rubocop

pull/484/head
baarkerlounger 3 years ago
parent
commit
2f73d250d1
  1. 2
      app/helpers/details_table_helper.rb
  2. 2
      app/services/imports/organisation_la_import_service.rb
  3. 11
      spec/helpers/details_table_helper_spec.rb
  4. 2
      spec/models/organisation_spec.rb
  5. 6
      spec/services/imports/organisation_la_import_service_spec.rb

2
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| "<li>#{la}</li>"}.join("\n")
list = attribute[:value].map { |la| "<li>#{la}</li>" }.join("\n")
simple_format(list, { class: "govuk-list govuk-list--bullet" }, wrapper_tag: "ul")
else
simple_format(attribute[:value].to_s, {}, wrapper_tag: "div")

2
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!(

11
spec/helpers/table_details_helper_spec.rb → 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("<div>Dummy org</div>")
expect(details).to eq("<div>Dummy org</div>")
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("<ul class=\"govuk-list govuk-list--bullet\"><li>Camden</li>\n<br /><li>Westminster</li>\n<br /><li>Bristol</li></ul>")
expect(details).to eq("<ul class=\"govuk-list govuk-list--bullet\"><li>Camden</li>\n<br /><li>Westminster</li>\n<br /><li>Bristol</li></ul>")
end
end
end

2
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

6
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

Loading…
Cancel
Save