|
23 | 23 | end |
24 | 24 | end |
25 | 25 |
|
26 | | - context "Methods" do |
27 | | - describe "volume" do |
| 26 | + context "Scopes" do |
| 27 | + describe "with_volumes" do |
| 28 | + subject { described_class.with_volumes } |
| 29 | + |
28 | 30 | it "retrieves the amount of product that has been donated by manufacturer" do |
29 | 31 | mfg = create(:manufacturer) |
30 | 32 | create(:donation, :with_items, item_quantity: 15, source: Donation::SOURCES[:manufacturer], manufacturer: mfg) |
31 | | - expect(mfg.volume).to eq(15) |
| 33 | + |
| 34 | + expect(subject.first.volume).to eq(15) |
32 | 35 | end |
33 | 36 |
|
34 | 37 | it "retrieves the amount of product that has been donated by manufacturer from multiple donations" do |
35 | 38 | mfg = create(:manufacturer) |
36 | 39 | create(:donation, :with_items, item_quantity: 15, source: Donation::SOURCES[:manufacturer], manufacturer: mfg) |
37 | 40 | create(:donation, :with_items, item_quantity: 10, source: Donation::SOURCES[:manufacturer], manufacturer: mfg) |
38 | | - expect(mfg.volume).to eq(25) |
| 41 | + |
| 42 | + expect(subject.first.volume).to eq(25) |
39 | 43 | end |
40 | 44 |
|
41 | 45 | it "ignores the amount of product from other manufacturers" do |
42 | 46 | mfg = create(:manufacturer) |
43 | 47 | mfg2 = create(:manufacturer) |
44 | 48 | create(:donation, :with_items, item_quantity: 5, source: Donation::SOURCES[:manufacturer], manufacturer: mfg) |
45 | 49 | create(:donation, :with_items, item_quantity: 10, source: Donation::SOURCES[:manufacturer], manufacturer: mfg2) |
46 | | - expect(mfg.volume).to eq(5) |
| 50 | + |
| 51 | + expect(subject.first.volume).to eq(5) |
47 | 52 | end |
48 | 53 | end |
| 54 | + end |
49 | 55 |
|
| 56 | + context "Methods" do |
50 | 57 | describe "by_donation_date" do |
51 | 58 | before do |
52 | 59 | # Prepare manufacturers with donations for tests |
|
0 commit comments