This repository has been archived by the owner on Mar 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed problem with dashboard page and statistics but more specs are n…
…eeded for this object.
- Loading branch information
Showing
6 changed files
with
99 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,2 @@ | ||
describe Admin::DashboardController do | ||
before do | ||
create(:donation, amount: 10.0, created_at: 2.days.ago) | ||
create(:donation, amount: 10.0, created_at: 3.days.ago) | ||
create(:donation, amount: 10.0, created_at: 4.days.ago) | ||
create(:donation, amount: 10.0, created_at: 5.days.ago) | ||
create(:donation, amount: 10.0, created_at: 6.days.ago) | ||
create(:donation, amount: 10.0, created_at: 7.days.ago) | ||
create(:donation, amount: 10.0, created_at: 8.days.ago) | ||
end | ||
|
||
subject { Statistics.new } | ||
its(:total_donations) {should eq 70.0} | ||
its(:average_donations_per_day) {should eq 10.0} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
describe Statistics do | ||
|
||
context "donation totals" do | ||
subject { Statistics.new } | ||
|
||
context "with no donations" do | ||
specify { expect(subject.total_donations).to eq(0.0) } | ||
end | ||
|
||
context "with multiple donations" do | ||
before { 3.times { create :donation, amount: 10.0 } } | ||
specify { expect(subject.total_donations).to eq(30.0) } | ||
end | ||
end | ||
|
||
context "donation averages" do | ||
subject { Statistics.new } | ||
|
||
context "with no donations" do | ||
specify { expect(subject.average_donations_per_day).to eq(0.0) } | ||
end | ||
|
||
context "with multiple donations" do | ||
before { 7.times { create :donation, amount: 10.0, created_at: 2.days.ago } } | ||
specify { expect(subject.average_donations_per_day).to eq(10.0) } | ||
end | ||
end | ||
|
||
end |