|
1 | | -RSpec.describe Exports::ExportAdjustmentsCSVService do |
| 1 | +RSpec.describe Exports::ExportAdjustmentsCSVService, :wip do |
2 | 2 | # Create organization after items to ensure proper associations |
3 | 3 | let!(:item1) { create(:item, name: 'item1') } |
4 | 4 | let!(:item2) { create(:item, name: 'item2') } |
|
21 | 21 |
|
22 | 22 | let(:expected_headers) do |
23 | 23 | [ |
24 | | - "Created", "Storage Location", |
25 | | - "Comment", "User", "Changes" |
| 24 | + "Created date", "Storage Area", |
| 25 | + "Comment", "# of changes" |
26 | 26 | ] + sorted_item_names |
27 | 27 | end |
28 | 28 |
|
|
77 | 77 | adjustments[0].created_at.strftime("%F"), |
78 | 78 | storage_location.name, |
79 | 79 | "adjustment 1", |
80 | | - user.name, |
81 | 80 | 2 # Number of items changed |
82 | 81 | ) |
83 | 82 |
|
|
86 | 85 | adjustments[1].created_at.strftime("%F"), |
87 | 86 | storage_location.name, |
88 | 87 | "adjustment 2", |
89 | | - user.name, |
90 | 88 | 1 # Number of items changed |
91 | 89 | ) |
92 | 90 |
|
|
95 | 93 | adjustments[2].created_at.strftime("%F"), |
96 | 94 | storage_location.name, |
97 | 95 | "adjustment 3", |
98 | | - user.name, |
99 | 96 | 1 # Number of items changed |
100 | 97 | ) |
101 | 98 | end |
|
131 | 128 | end |
132 | 129 |
|
133 | 130 | it "should correctly sum up the number of changes" do |
134 | | - idx = expected_headers.index("Changes") |
| 131 | + idx = expected_headers.index("# of changes") |
135 | 132 | expect(subject[1][idx]).to eq(2) |
136 | 133 | expect(subject[2][idx]).to eq(1) |
137 | 134 | expect(subject[3][idx]).to eq(1) |
|
166 | 163 | it "generates valid CSV data" do |
167 | 164 | expect(subject).to be_a(String) |
168 | 165 | parsed_csv = CSV.parse(subject, headers: true) |
169 | | - expect(parsed_csv.headers).to include("Created", |
170 | | - "Storage Location", |
| 166 | + expect(parsed_csv.headers).to include("Created date", |
| 167 | + "Storage Area", |
171 | 168 | "Comment", |
172 | | - "Changes", |
| 169 | + "# of changes", |
173 | 170 | item1.name, |
174 | 171 | item2.name, |
175 | 172 | item3.name, |
176 | 173 | item4.name) |
177 | 174 |
|
178 | | - expect(parsed_csv.first["Changes"]).to eq("2") |
| 175 | + expect(parsed_csv.first["# of changes"]).to eq("2") |
179 | 176 | expect(parsed_csv.first[item1.name]).to eq("111") |
180 | 177 | expect(parsed_csv.first[item2.name]).to eq("-7") |
181 | 178 | end |
|
0 commit comments