From b798647a20568a6b8f6ccb98ba3713e946ca93ba Mon Sep 17 00:00:00 2001 From: Alex Parsons Date: Mon, 18 Jul 2022 11:28:35 +0100 Subject: [PATCH 1/2] Add the internal ID number to the CSV download Required for research purposes where the ID has been passed to a survey platform and responses need to be tied back to authorities. --- lib/public_body_csv.rb | 6 ++++-- spec/lib/public_body_csv_spec.rb | 14 ++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/public_body_csv.rb b/lib/public_body_csv.rb index 15526ce9ad..5438db936d 100644 --- a/lib/public_body_csv.rb +++ b/lib/public_body_csv.rb @@ -19,7 +19,8 @@ class PublicBodyCSV def self.default_fields - [:name, + [:id, + :name, :short_name, :url_name, :tag_string, @@ -34,7 +35,8 @@ def self.default_fields # TODO: Generate headers from fields def self.default_headers - ['Name', + ['Internal ID', + 'Name', 'Short name', 'URL name', 'Tags', diff --git a/spec/lib/public_body_csv_spec.rb b/spec/lib/public_body_csv_spec.rb index d4bf411813..3c6c431ec0 100644 --- a/spec/lib/public_body_csv_spec.rb +++ b/spec/lib/public_body_csv_spec.rb @@ -5,7 +5,8 @@ describe '.default_fields' do it 'has a default set of fields' do - defaults = [:name, + defaults = [:id, + :name, :short_name, :url_name, :tag_string, @@ -23,7 +24,8 @@ describe '.default_headers' do it 'has a default set of headers' do - defaults = ['Name', + defaults = ['Internal ID', + 'Name', 'Short name', 'URL name', 'Tags', @@ -39,13 +41,13 @@ end describe '.export' do - it 'should return a valid CSV file with the right number of rows' do + it 'should return a valid CSV file with the right number of rows/columns' do all_data = CSV.parse(PublicBodyCSV.export) expect(all_data.length).to eq(7) # Check that the header has the right number of columns: - expect(all_data[0].length).to eq(11) + expect(all_data[0].length).to eq(12) # And an actual line of data: - expect(all_data[1].length).to eq(11) + expect(all_data[1].length).to eq(12) end it 'only includes visible bodies' do @@ -125,7 +127,7 @@ csv = PublicBodyCSV.new csv << body - expected = ["Exported to CSV,CSV,csv,exported,https://www.localhost,\"\",\"\",An exported authority,2007-10-25 10:51:01 UTC,2007-10-25 10:51:01 UTC,1"] + expected = ["#{body.id},Exported to CSV,CSV,csv,exported,https://www.localhost,\"\",\"\",An exported authority,2007-10-25 10:51:01 UTC,2007-10-25 10:51:01 UTC,1"] expect(csv.rows).to eq(expected) end From 3376accc176704b896d806a37e0c35dec11e596f Mon Sep 17 00:00:00 2001 From: Graeme Porteous Date: Wed, 25 Oct 2023 10:19:24 +0100 Subject: [PATCH 2/2] Update changelog --- doc/CHANGES.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 678af1cf60..c7deca59dd 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -1,3 +1,10 @@ +# develop + +## Highlighted Features + +* Add internal ID number to authority CSV download (Alex Pearson, Graeme + Porteous) + # 0.44.0.0 ## Highlighted Features