|
2 | 2 | # |
3 | 3 | RSpec.describe OrganizationStats, type: :model do |
4 | 4 | let(:current_org) { create(:organization) } |
| 5 | + let(:inventory) { View::Inventory.new(current_org.id) } |
5 | 6 |
|
6 | | - subject { described_class.new(current_org) } |
| 7 | + subject { described_class.new(current_org, inventory) } |
7 | 8 |
|
8 | 9 | describe "partners_added method >" do |
9 | 10 | context "current org is nil >" do |
10 | 11 | let(:current_org) { nil } |
| 12 | + let(:inventory) { nil } |
11 | 13 |
|
12 | 14 | it "should return 0" do |
13 | 15 | expect(subject.partners_added).to eq(0) |
|
28 | 30 | describe "storage_locations_added method >" do |
29 | 31 | context "current org is nil >" do |
30 | 32 | let(:current_org) { nil } |
| 33 | + let(:inventory) { nil } |
31 | 34 |
|
32 | 35 | it "should return 0" do |
33 | 36 | expect(subject.storage_locations_added).to eq(0) |
|
48 | 51 | describe "donation_sites_added method >" do |
49 | 52 | context "current org is nil >" do |
50 | 53 | let(:current_org) { nil } |
| 54 | + let(:inventory) { nil } |
51 | 55 |
|
52 | 56 | it "should return 0" do |
53 | 57 | expect(subject.donation_sites_added).to eq(0) |
|
65 | 69 | end |
66 | 70 | end |
67 | 71 |
|
68 | | - describe "locations_with_inventory method >" do |
| 72 | + describe "num_locations_with_inventory method >" do |
69 | 73 | context "current org is nil >" do |
70 | 74 | let(:current_org) { nil } |
| 75 | + let(:inventory) { nil } |
71 | 76 |
|
72 | 77 | it "should return an empty array" do |
73 | | - expect(subject.locations_with_inventory).to eq([]) |
| 78 | + expect(subject.num_locations_with_inventory).to eq(0) |
74 | 79 | end |
75 | 80 | end |
76 | 81 |
|
|
87 | 92 | end |
88 | 93 |
|
89 | 94 | it "should return storage location" do |
90 | | - expect(subject.locations_with_inventory).to include(storage_location_1) |
| 95 | + expect(subject.num_locations_with_inventory).to eq(1) |
91 | 96 | end |
92 | 97 | end |
93 | 98 |
|
|
96 | 101 | let(:storage_locations) { [storage_location_1] } |
97 | 102 |
|
98 | 103 | it "should return an empty array" do |
99 | | - expect(subject.locations_with_inventory).to eq([]) |
| 104 | + expect(subject.num_locations_with_inventory).to eq(0) |
100 | 105 | end |
101 | 106 | end |
102 | 107 | end |
|
0 commit comments