Skip to content

Commit

Permalink
Update export to include not_provided_by_authority col and field data
Browse files Browse the repository at this point in the history
  • Loading branch information
georges1996 committed May 27, 2024
1 parent cfaf44a commit 77fcd61
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
3 changes: 3 additions & 0 deletions app/lib/local_links_manager/export/links_exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class LinksExporter
:lgil_code,
:url,
:enabled,
:not_provided_by_authority,
].freeze
COMMON_HEADINGS = [
"Authority Name",
Expand All @@ -22,6 +23,7 @@ class LinksExporter
"LGIL",
"URL",
"Supported by GOV.UK",
"Not Provided by Authority",
].freeze
EXTRA_HEADINGS = ["Status", "New URL"].freeze

Expand Down Expand Up @@ -71,6 +73,7 @@ def format(record)
record.lgil_code,
record.url,
record.enabled,
record.not_provided_by_authority,
]
end

Expand Down
12 changes: 6 additions & 6 deletions spec/lib/local-links-manager/export/fixtures/exported_links.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Authority Name,GSS,Description,LGSL,LGIL,URL,Supported by GOV.UK
Exeter,456,Service 123: Interaction 0,123,0,http://www.example.com/456/0,true
Exeter,456,Service 123: Interaction 1,123,1,http://www.example.com/456/1,true
Exeter,456,Service 666: Interaction 0,666,0,http://www.example.com/456/0,false
London,123,Service 123: Interaction 0,123,0,http://www.example.com/123/0,true
London,123,Service 123: Interaction 1,123,1,http://www.example.com/123/1,true
Authority Name,GSS,Description,LGSL,LGIL,URL,Supported by GOV.UK,Not Provided by Authority
Exeter,456,Service 123: Interaction 0,123,0,http://www.example.com/456/0,true,false
Exeter,456,Service 123: Interaction 1,123,1,http://www.example.com/456/1,true,false
Exeter,456,Service 666: Interaction 0,666,0,http://www.example.com/456/0,false,false
London,123,Service 123: Interaction 0,123,0,http://www.example.com/123/0,true,false
London,123,Service 123: Interaction 1,123,1,http://www.example.com/123/1,true,false
4 changes: 2 additions & 2 deletions spec/lib/local-links-manager/export/fixtures/ni_link.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Authority Name,GSS,Description,LGSL,LGIL,URL,Supported by GOV.UK
Belfast,456,Service 123: Interaction 1,123,1,http://www.example.com/456/1,true
Authority Name,GSS,Description,LGSL,LGIL,URL,Supported by GOV.UK,Not Provided by Authority
Belfast,456,Service 123: Interaction 1,123,1,http://www.example.com/456/1,true,false
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_url(local_authority, interaction)

it "exports links which have a not_provided_by_authority of true" do
expect(csv).to include(headings)
expect(csv).to include("#{la.name},#{la.gss},#{not_provided_by_authority_link.service.label}: #{not_provided_by_authority_link.interaction.label},#{not_provided_by_authority_link.service.lgsl_code},#{not_provided_by_authority_link.interaction.lgil_code},#{not_provided_by_authority_link.url},#{not_provided_by_authority_link.service.enabled},#{not_provided_by_authority_link.status}")
expect(csv).to include("#{la.name},#{la.gss},#{not_provided_by_authority_link.service.label}: #{not_provided_by_authority_link.interaction.label},#{not_provided_by_authority_link.service.lgsl_code},#{not_provided_by_authority_link.interaction.lgil_code},#{not_provided_by_authority_link.url},#{not_provided_by_authority_link.service.enabled},#{not_provided_by_authority_link.not_provided_by_authority},#{not_provided_by_authority_link.status}")
end
end

Expand All @@ -96,18 +96,18 @@ def test_url(local_authority, interaction)
it "exports #{status} links for enabled services for a given local authority to CSV format with headings" do
expect(csv).to include(headings)
links.slice(status).each_value do |link|
expect(csv).to include("#{la.name},#{la.gss},#{link.service.label}: #{link.interaction.label},#{link.service.lgsl_code},#{link.interaction.lgil_code},#{link.url},#{link.service.enabled},#{link.status}")
expect(csv).to include("#{la.name},#{la.gss},#{link.service.label}: #{link.interaction.label},#{link.service.lgsl_code},#{link.interaction.lgil_code},#{link.url},#{link.service.enabled},#{link.not_provided_by_authority},#{link.status}")
end
end

it "does not export links for disabled services" do
expect(csv).to_not include("#{la.name},#{la.gss},#{disabled_link.service.label}: #{disabled_link.interaction.label},#{disabled_link.service.lgsl_code},#{disabled_link.interaction.lgil_code},#{disabled_link.url},#{disabled_link.service.enabled},#{disabled_link.status}")
expect(csv).to_not include("#{la.name},#{la.gss},#{disabled_link.service.label}: #{disabled_link.interaction.label},#{disabled_link.service.lgsl_code},#{disabled_link.interaction.lgil_code},#{disabled_link.url},#{disabled_link.service.enabled},#{disabled_link.not_provided_by_authority},#{disabled_link.status}")
end

(%w[ok broken caution missing pending] - [status]).each do |status_not_in_params|
it "does not export #{status_not_in_params} links" do
links.except(status).each_value do |link|
expect(csv).to_not include("#{la.name},#{la.gss},#{link.service.label}: #{link.interaction.label},#{link.service.lgsl_code},#{link.interaction.lgil_code},#{link.url},#{link.service.enabled},#{link.status}")
expect(csv).to_not include("#{la.name},#{la.gss},#{link.service.label}: #{link.interaction.label},#{link.service.lgsl_code},#{link.interaction.lgil_code},#{link.url},#{link.service.enabled},#{link.not_provided_by_authority},#{link.status}")
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def fixture_file(file)
let(:csv) { exporter.export_links(service.id, %w[ok], true) }

it "exports links which have a not_provided_by_authority of true" do
expect(csv).to include("#{not_provided_by_authority_link.local_authority.name},#{not_provided_by_authority_link.local_authority.gss},#{not_provided_by_authority_link.service.label}: #{not_provided_by_authority_link.interaction.label},#{not_provided_by_authority_link.service.lgsl_code},#{not_provided_by_authority_link.interaction.lgil_code},#{not_provided_by_authority_link.url},#{not_provided_by_authority_link.service.enabled},#{not_provided_by_authority_link.status}")
expect(csv).to include("#{not_provided_by_authority_link.local_authority.name},#{not_provided_by_authority_link.local_authority.gss},#{not_provided_by_authority_link.service.label}: #{not_provided_by_authority_link.interaction.label},#{not_provided_by_authority_link.service.lgsl_code},#{not_provided_by_authority_link.interaction.lgil_code},#{not_provided_by_authority_link.url},#{not_provided_by_authority_link.service.enabled},#{not_provided_by_authority_link.not_provided_by_authority},#{not_provided_by_authority_link.status}")
end
end

Expand All @@ -45,7 +45,7 @@ def fixture_file(file)
it "exports #{status} links for enabled services for a given local authority to CSV format with headings" do
expect(csv).to include(headings)
links.slice(status).each_value do |link|
expect(csv).to include("#{link.local_authority.name},#{link.local_authority.gss},#{link.service.label}: #{link.interaction.label},#{link.service.lgsl_code},#{link.interaction.lgil_code},#{link.url},#{link.service.enabled},#{link.status}")
expect(csv).to include("#{link.local_authority.name},#{link.local_authority.gss},#{link.service.label}: #{link.interaction.label},#{link.service.lgsl_code},#{link.interaction.lgil_code},#{link.url},#{link.service.enabled},#{link.not_provided_by_authority},#{link.status}")
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/tasks/export/link_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
la = LocalAuthority.last
interaction = service_interaction.interaction
expected_body = <<~EXPECTED_BODY_TEXT
Authority Name,GSS,Description,LGSL,LGIL,URL,Supported by GOV.UK
#{la.name},#{la.gss},#{service.label}: #{interaction.label},#{service.lgsl_code},#{interaction.lgil_code},#{link.url},true
Authority Name,GSS,Description,LGSL,LGIL,URL,Supported by GOV.UK,Not Provided by Authority
#{la.name},#{la.gss},#{service.label}: #{interaction.label},#{service.lgsl_code},#{interaction.lgil_code},#{link.url},true,false
EXPECTED_BODY_TEXT

s3 = double
Expand Down

0 comments on commit 77fcd61

Please sign in to comment.