|
15 | 15 | disposable_kit_item = create(:item, name: "Adult Disposable Diapers", partner_key: "adult diapers") |
16 | 16 | another_disposable_kit_item = create(:item, name: "Infant Disposable Diapers", partner_key: "infant diapers") |
17 | 17 |
|
18 | | - disposable_line_item = create(:line_item, item: disposable_kit_item, quantity: 5) |
19 | | - another_disposable_line_item = create(:line_item, item: another_disposable_kit_item, quantity: 5) |
| 18 | + disposable_kit = create_kit(organization: organization, line_items_attributes: [ |
| 19 | + {item_id: disposable_kit_item.id, quantity: 5} |
| 20 | + ]) |
20 | 21 |
|
21 | | - disposable_kit = create(:kit, :with_item, organization: organization, line_items: [disposable_line_item]) |
22 | | - another_disposable_kit = create(:kit, :with_item, organization: organization, line_items: [another_disposable_line_item]) |
| 22 | + another_disposable_kit = create_kit(organization: organization, line_items_attributes: [ |
| 23 | + {item_id: another_disposable_kit_item.id, quantity: 5} |
| 24 | + ]) |
23 | 25 |
|
24 | 26 | disposable_kit_item_distribution = create(:distribution, organization: organization, issued_at: within_time) |
25 | 27 | another_disposable_kit_item_distribution = create(:distribution, organization: organization, issued_at: within_time) |
26 | 28 |
|
27 | 29 | create(:line_item, :distribution, quantity: 10, item: disposable_kit.item, itemizable: disposable_kit_item_distribution) |
28 | 30 | create(:line_item, :distribution, quantity: 10, item: another_disposable_kit.item, itemizable: another_disposable_kit_item_distribution) |
| 31 | + # Total disposable items distributed so far: 5*10 + 5*10 = 100 |
29 | 32 |
|
30 | 33 | # create disposable and non disposable items |
31 | 34 | create(:base_item, name: "3T Diaper", partner_key: "toddler diapers", category: "disposable diaper") |
|
42 | 45 | create_list(:line_item, 5, :distribution, quantity: 20, item: disposable_item, itemizable: dist) |
43 | 46 | create_list(:line_item, 5, :distribution, quantity: 30, item: non_disposable_item, itemizable: dist) |
44 | 47 | end |
| 48 | + # Total disposable items distributed: (100) + 2*5*20 = 300 |
45 | 49 |
|
46 | 50 | # Donations outside drives |
47 | 51 | non_drive_donations = create_list(:donation, 2, |
|
155 | 159 |
|
156 | 160 | it "should return the proper results on #report" do |
157 | 161 | expect(subject.report).to eq({ |
158 | | - entries: {"Disposable diapers distributed" => "320", |
| 162 | + entries: {"Disposable diapers distributed" => "300", |
159 | 163 | "Cloth diapers distributed" => "300", |
160 | | - "Average monthly disposable diapers distributed" => "27", |
| 164 | + "Average monthly disposable diapers distributed" => "25", |
161 | 165 | "Total product drives" => 2, |
162 | 166 | "Disposable diapers collected from drives" => "600", |
163 | 167 | "Cloth diapers collected from drives" => "900", |
|
0 commit comments