Skip to content

Commit dc4477d

Browse files
Lint and update field names
1 parent 11efa3c commit dc4477d

File tree

2 files changed

+245
-244
lines changed

2 files changed

+245
-244
lines changed

spec/lib/appropriate_bodies/importers/appropriate_body_importer_spec.rb

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
describe AppropriateBodies::Importers::AppropriateBodyImporter do
2-
let!(:ab_1) { FactoryBot.create(:appropriate_body, legacy_id: '025e61e7-ec32-eb11-a813-000d3a228dfc') }
3-
let!(:ab_2) { FactoryBot.create(:appropriate_body, legacy_id: '1ddf3e82-c1ae-e311-b8ed-005056822391') }
2+
subject { AppropriateBodies::Importers::AppropriateBodyImporter.new(nil, wanted_legacy_ids, nil, csv: sample_appropriate_body_csv, dfe_sign_in_mapping_csv: sample_mapping_csv) }
3+
4+
let!(:ab_1) { FactoryBot.create(:appropriate_body, dqt_id: "025e61e7-ec32-eb11-a813-000d3a228dfc") }
5+
let!(:ab_2) { FactoryBot.create(:appropriate_body, dqt_id: "1ddf3e82-c1ae-e311-b8ed-005056822391") }
46

5-
let(:wanted_legacy_ids) { [ab_1.legacy_id, ab_2.legacy_id] }
7+
let(:wanted_legacy_ids) { [ab_1.dqt_id, ab_2.dqt_id] }
68

79
let(:sample_appropriate_body_data) do
810
<<~CSV
911
id,name,dfe_sign_in_organisation_id,local_authority_code,establishment_number
10-
#{ab_1.legacy_id},Testington Primary School,1234568,123/4567,
11-
#{ab_2.legacy_id},Sampleville Primary School,23456789,987/6543,
12+
#{ab_1.dqt_id},Testington Primary School,1234568,123/4567,
13+
#{ab_2.dqt_id},Sampleville Primary School,23456789,987/6543,
1214
CSV
1315
end
1416

@@ -23,137 +25,135 @@
2325

2426
let(:sample_mapping_csv) { CSV.parse(sample_mapping_data, headers: true) }
2527

26-
subject { AppropriateBodies::Importers::AppropriateBodyImporter.new(nil, wanted_legacy_ids, nil, csv: sample_appropriate_body_csv, dfe_sign_in_mapping_csv: sample_mapping_csv) }
27-
28-
it 'converts the csv row to Row objects when initialized' do
28+
it "converts the csv row to Row objects when initialized" do
2929
expect(subject.rows).to all(be_a(AppropriateBodies::Importers::AppropriateBodyImporter::Row))
3030
end
3131

32-
describe 'setting the local authority code and establishment number' do
33-
context 'when the format is DDD' do
32+
describe "setting the local authority code and establishment number" do
33+
context "when the format is DDD" do
3434
let(:sample_appropriate_body_data) do
3535
<<~CSV
3636
id,name,dfe_sign_in_organisation_id,local_authority_code,establishment_number
37-
#{ab_1.legacy_id},Chesterton Primary School,1234568,123
37+
#{ab_1.dqt_id},Chesterton Primary School,1234568,123
3838
CSV
3939
end
4040

41-
it 'sets the local4 authority code to 123' do
41+
it "sets the local4 authority code to 123" do
4242
expect(subject.rows[0].local_authority_code).to eql(123)
4343
end
4444
end
4545

46-
context 'when the format is DDDD' do
46+
context "when the format is DDDD" do
4747
let(:sample_appropriate_body_data) do
4848
<<~CSV
4949
id,name,dfe_sign_in_organisation_id,local_authority_code,establishment_number
50-
#{ab_1.legacy_id},Chesterton Primary School,1234568,1234
50+
#{ab_1.dqt_id},Chesterton Primary School,1234568,1234
5151
CSV
5252
end
5353

54-
it 'sets the establishment number to 1234' do
54+
it "sets the establishment number to 1234" do
5555
expect(subject.rows[0].establishment_number).to eql(1234)
5656
end
5757
end
5858

59-
context 'when the appropriate body legacy_id is in the list of wanted_legacy_ids' do
60-
it 'parses and builds the rows' do
59+
context "when the appropriate body legacy_id is in the list of wanted_legacy_ids" do
60+
it "parses and builds the rows" do
6161
expect(subject.rows.map(&:legacy_id)).to match_array(wanted_legacy_ids)
6262
end
6363
end
6464

65-
context 'when the appropriate body legacy_id is not in the list of wanted_legacy_ids' do
66-
let(:wanted_legacy_ids) { [ab_1.legacy_id] }
65+
context "when the appropriate body legacy_id is not in the list of wanted_legacy_ids" do
66+
let(:wanted_legacy_ids) { [ab_1.dqt_id] }
6767

68-
it 'omits the unwanted rows' do
68+
it "omits the unwanted rows" do
6969
parsed_legacy_ids = subject.rows.map(&:legacy_id)
7070

71-
expect(parsed_legacy_ids).to include(ab_1.legacy_id)
72-
expect(parsed_legacy_ids).not_to include(ab_2.legacy_id)
71+
expect(parsed_legacy_ids).to include(ab_1.dqt_id)
72+
expect(parsed_legacy_ids).not_to include(ab_2.dqt_id)
7373
end
7474
end
7575

76-
context 'when the format is DDDD/DDD' do
76+
context "when the format is DDDD/DDD" do
7777
let(:sample_appropriate_body_data) do
7878
<<~CSV
7979
id,name,dfe_sign_in_organisation_id,local_authority_code,establishment_number
80-
#{ab_1.legacy_id},Chesterton Primary School,1234568,567/1234
80+
#{ab_1.dqt_id},Chesterton Primary School,1234568,567/1234
8181
CSV
8282
end
8383

84-
it 'sets the establishment number to 1234' do
84+
it "sets the establishment number to 1234" do
8585
expect(subject.rows[0].establishment_number).to eql(1234)
8686
end
8787

88-
it 'sets the local authority code to 567' do
88+
it "sets the local authority code to 567" do
8989
expect(subject.rows[0].local_authority_code).to eql(567)
9090
end
9191
end
9292

93-
context 'when the format is DDDDDDD' do
93+
context "when the format is DDDDDDD" do
9494
let(:sample_appropriate_body_data) do
9595
<<~CSV
9696
id,name,dfe_sign_in_organisation_id,local_authority_code,establishment_number
97-
#{ab_1.legacy_id},Chesterton Primary School,1234568,5671234
97+
#{ab_1.dqt_id},Chesterton Primary School,1234568,5671234
9898
CSV
9999
end
100100

101-
it 'sets the establishment number to 1234' do
101+
it "sets the establishment number to 1234" do
102102
expect(subject.rows[0].establishment_number).to eql(1234)
103103
end
104104

105-
it 'sets the local authority code to 567' do
105+
it "sets the local authority code to 567" do
106106
expect(subject.rows[0].local_authority_code).to eql(567)
107107
end
108108
end
109109
end
110110

111-
describe 'setting the name' do
112-
context 'when there is no mapping in place' do
113-
it 'sets the appropriate body name to the name field from the appropriate bodies csv' do
114-
expect(subject.rows.map(&:name)).to match_array(['Testington Primary School', 'Sampleville Primary School'])
111+
describe "setting the name" do
112+
context "when there is no mapping in place" do
113+
it "sets the appropriate body name to the name field from the appropriate bodies csv" do
114+
expect(subject.rows.map(&:name)).to contain_exactly("Testington Primary School", "Sampleville Primary School")
115115
end
116116
end
117117

118-
context 'when there is a mapping in place' do
118+
context "when there is a mapping in place" do
119119
let(:sample_mapping_data) do
120120
<<~CSV
121121
appropriate_body_name,lead_school_name,dfe_sign_in_organisation_id,dqt_id
122-
Test TSH,Test Lead School,203606a4-4199-46a9-84e4-56fbc5da2a36,#{ab_1.legacy_id}
122+
Test TSH,Test Lead School,203606a4-4199-46a9-84e4-56fbc5da2a36,#{ab_1.dqt_id}
123123
CSV
124124
end
125125

126-
it 'sets the appropriate body name to the appropriate body name field from the mapping bodies csv' do
127-
expect(subject.rows.map(&:name)).to match_array(['Test TSH', 'Sampleville Primary School'])
126+
it "sets the appropriate body name to the appropriate body name field from the mapping bodies csv" do
127+
expect(subject.rows.map(&:name)).to contain_exactly("Test TSH", "Sampleville Primary School")
128128
end
129129
end
130130
end
131131

132-
describe 'setting the DfE Sign-in ID' do
133-
context 'when there is no mapping in place' do
134-
it 'sets the DfE Sign-in ID to nil' do
132+
describe "setting the DfE Sign-in ID" do
133+
context "when there is no mapping in place" do
134+
it "sets the DfE Sign-in ID to nil" do
135135
expect(subject.rows.map(&:dfe_sign_in_organisation_id)).to all(be_nil)
136136
end
137137
end
138138

139-
context 'when there is a mapping in place' do
139+
context "when there is a mapping in place" do
140140
let(:dfe_sign_in_organisation_id) { SecureRandom.uuid }
141141

142142
let(:sample_mapping_data) do
143143
<<~CSV
144144
appropriate_body_name,lead_school_name,dfe_sign_in_organisation_id,dqt_id
145-
Test TSH,Test Lead School,#{dfe_sign_in_organisation_id},#{ab_1.legacy_id}
145+
Test TSH,Test Lead School,#{dfe_sign_in_organisation_id},#{ab_1.dqt_id}
146146
CSV
147147
end
148148

149-
it 'sets the DfE Sign-in ID to the value from the mappings CSV' do
150-
ab_1_row = subject.rows.find { |r| r.legacy_id == ab_1.legacy_id }
149+
it "sets the DfE Sign-in ID to the value from the mappings CSV" do
150+
ab_1_row = subject.rows.find { |r| r.legacy_id == ab_1.dqt_id }
151151

152152
expect(ab_1_row.dfe_sign_in_organisation_id).to eql(dfe_sign_in_organisation_id)
153153
end
154154

155-
it 'is nil when there is no mapping' do
156-
ab_2_row = subject.rows.find { |r| r.legacy_id == ab_2.legacy_id }
155+
it "is nil when there is no mapping" do
156+
ab_2_row = subject.rows.find { |r| r.legacy_id == ab_2.dqt_id }
157157

158158
expect(ab_2_row.dfe_sign_in_organisation_id).to be_nil
159159
end

0 commit comments

Comments
 (0)