-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add the ability to compute the sum of a given column in query sets * Fix ameba finding * Fix findings
- Loading branch information
Showing
6 changed files
with
119 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -788,6 +788,16 @@ describe Marten::DB::Model::Querying do | |
end | ||
end | ||
|
||
describe "::sum" do | ||
it "properly calculates the sum" do | ||
user = TestUser.create!(username: "jd1", email: "[email protected]", first_name: "John", last_name: "Doe") | ||
Post.create!(author: user, title: "Example post 1", score: 5.0) | ||
Post.create!(author: user, title: "Example post 2", score: 5.0) | ||
|
||
Post.sum(:score).should eq 10.00 | ||
end | ||
end | ||
|
||
describe "::using" do | ||
before_each do | ||
TestUser.using(:other).create!(username: "jd1", email: "[email protected]", first_name: "John", last_name: "Doe") | ||
|
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