Skip to content

Commit d00262f

Browse files
CodeCorvinthomasleese
authored andcommitted
Merge branch 'next' into enable_dismiss_important_notices_for_archived_patients
2 parents 97341ed + 9e018c3 commit d00262f

6 files changed

Lines changed: 32 additions & 104 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PARENT_1_NAME,PARENT_1_RELATIONSHIP,PARENT_1_EMAIL,PARENT_1_PHONE,PARENT_2_NAME,PARENT_2_RELATIONSHIP,PARENT_2_EMAIL,PARENT_2_PHONE,CHILD_FIRST_NAME,CHILD_LAST_NAME,CHILD_PREFERRED_FIRST_NAME,CHILD_DATE_OF_BIRTH,CHILD_YEAR_GROUP,CHILD_ADDRESS_LINE_1,CHILD_ADDRESS_LINE_2,CHILD_TOWN,CHILD_POSTCODE,CHILD_REGISTRATION,CHILD_NHS_NUMBER
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CHILD_SCHOOL_URN,PARENT_1_NAME,PARENT_1_RELATIONSHIP,PARENT_1_EMAIL,PARENT_1_PHONE,PARENT_2_NAME,PARENT_2_RELATIONSHIP,PARENT_2_EMAIL,PARENT_2_PHONE,CHILD_FIRST_NAME,CHILD_LAST_NAME,CHILD_PREFERRED_GIVEN_NAME,CHILD_DATE_OF_BIRTH,CHILD_YEAR_GROUP,CHILD_ADDRESS_LINE_1,CHILD_ADDRESS_LINE_2,CHILD_TOWN,CHILD_POSTCODE,CHILD_NHS_NUMBER

spec/models/class_import_spec.rb

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,32 +50,6 @@
5050

5151
it_behaves_like "a CSVImportable model"
5252

53-
describe "#load_data!" do
54-
subject(:load_data!) { class_import.load_data! }
55-
56-
before { load_data! }
57-
58-
describe "with malformed CSV" do
59-
let(:file) { "malformed.csv" }
60-
61-
it "is invalid" do
62-
expect(class_import).to be_invalid
63-
expect(class_import.errors[:csv]).to include(/correct format/)
64-
end
65-
end
66-
67-
describe "with too many rows" do
68-
let(:file) { "valid.csv" }
69-
70-
before { stub_const("CSVImportable::MAX_CSV_ROWS", 2) }
71-
72-
it "is invalid" do
73-
expect(class_import).to be_invalid
74-
expect(class_import.errors[:csv]).to include(/less than 2 rows/)
75-
end
76-
end
77-
end
78-
7953
describe "#parse_rows!" do
8054
subject(:parse_rows!) { class_import.parse_rows! }
8155

spec/models/cohort_import_spec.rb

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -48,32 +48,6 @@
4848

4949
it_behaves_like "a CSVImportable model"
5050

51-
describe "#load_data!" do
52-
subject(:load_data!) { cohort_import.load_data! }
53-
54-
before { load_data! }
55-
56-
describe "with malformed CSV" do
57-
let(:file) { "malformed.csv" }
58-
59-
it "is invalid" do
60-
expect(cohort_import).to be_invalid
61-
expect(cohort_import.errors[:csv]).to include(/correct format/)
62-
end
63-
end
64-
65-
describe "with too many rows" do
66-
let(:file) { "valid.csv" }
67-
68-
before { stub_const("CSVImportable::MAX_CSV_ROWS", 2) }
69-
70-
it "is invalid" do
71-
expect(cohort_import).to be_invalid
72-
expect(cohort_import.errors[:csv]).to include(/less than 2 rows/)
73-
end
74-
end
75-
end
76-
7751
describe "#parse_rows!" do
7852
subject(:parse_rows!) { cohort_import.parse_rows! }
7953

@@ -153,28 +127,6 @@
153127
expect(cohort_import.errors.to_a[0]).to start_with("Row 2")
154128
end
155129
end
156-
157-
describe "with a valid file using ISO-8859-1 encoding" do
158-
let(:file) { "valid_iso_8859_1_encoding.csv" }
159-
160-
let(:location) do
161-
Location.find_by_urn_and_site("120026") ||
162-
create(:gias_school, urn: "120026", team:)
163-
end
164-
165-
it "is valid" do
166-
expect(cohort_import).to be_valid
167-
expect(cohort_import.rows.count).to eq(16)
168-
end
169-
end
170-
171-
describe "with an invalid file using ISO-8859-1 encoding" do
172-
let(:file) { "invalid_iso_8859_1_encoding.csv" }
173-
174-
it "is invalid" do
175-
expect(cohort_import).to be_invalid
176-
end
177-
end
178130
end
179131

180132
describe "#process!" do

spec/models/immunisation_import_spec.rb

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -66,35 +66,6 @@
6666
describe "#load_data!" do
6767
before { immunisation_import.load_data! }
6868

69-
context "with malformed CSV" do
70-
let(:file) { "malformed.csv" }
71-
72-
it "is invalid" do
73-
expect(immunisation_import).to be_invalid
74-
expect(immunisation_import.errors[:csv]).to include(/correct format/)
75-
end
76-
end
77-
78-
context "with empty CSV" do
79-
let(:file) { "empty.csv" }
80-
81-
it "is invalid" do
82-
expect(immunisation_import).to be_invalid
83-
expect(immunisation_import.errors[:csv]).to include(/one record/)
84-
end
85-
end
86-
87-
context "with too many rows" do
88-
let(:file) { "valid_flu.csv" }
89-
90-
before { stub_const("CSVImportable::MAX_CSV_ROWS", 2) }
91-
92-
it "is invalid" do
93-
expect(immunisation_import).to be_invalid
94-
expect(immunisation_import.errors[:csv]).to include(/less than 2 rows/)
95-
end
96-
end
97-
9869
context "with a duplicated row" do
9970
let(:file) { "duplicate_row.csv" }
10071

spec/support/shared_examples/a_csv_importable_model.rb

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# frozen_string_literal: true
22

33
shared_examples_for "a CSVImportable model" do
4-
describe "validations" do
4+
describe "#load_data!" do
5+
before { subject.load_data! }
6+
57
it { should be_valid }
68

79
it { should validate_presence_of(:csv_filename) }
@@ -20,6 +22,33 @@
2022
subject.update!(processed_at: Time.zone.now, status: :processed)
2123
}.to raise_error(/Count statistics must be set/)
2224
end
25+
26+
describe "with malformed CSV" do
27+
let(:file) { "malformed.csv" }
28+
29+
it "is invalid" do
30+
expect(subject).to be_invalid
31+
expect(subject.errors[:csv]).to include(/correct format/)
32+
end
33+
end
34+
35+
describe "with too many rows" do
36+
before { stub_const("CSVImportable::MAX_CSV_ROWS", 2) }
37+
38+
it "is invalid" do
39+
expect(subject).to be_invalid
40+
expect(subject.errors[:csv]).to include(/less than 2 rows/)
41+
end
42+
end
43+
44+
context "with empty CSV" do
45+
let(:file) { "empty.csv" }
46+
47+
it "is invalid" do
48+
expect(subject).to be_invalid
49+
expect(subject.errors[:csv]).to include(/one record/)
50+
end
51+
end
2352
end
2453

2554
describe "#csv=" do

0 commit comments

Comments
 (0)