mongoid 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.4
1
+ 1.2.5
@@ -203,7 +203,7 @@ module Mongoid #:nodoc:
203
203
  reduce.gsub("[field]", field),
204
204
  true
205
205
  )
206
- collection.first[start.to_s]
206
+ collection.empty? ? nil : collection.first[start.to_s]
207
207
  end
208
208
 
209
209
  # Filters the field list. If no fields have been supplied, then it will be
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid}
8
- s.version = "1.2.4"
8
+ s.version = "1.2.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Durran Jordan"]
12
- s.date = %q{2010-02-09}
12
+ s.date = %q{2010-02-10}
13
13
  s.email = %q{durran@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.rdoc"
@@ -52,44 +52,65 @@ describe Mongoid::Criteria do
52
52
 
53
53
  describe "#max" do
54
54
 
55
- before do
56
- 10.times do |n|
57
- Person.create(:title => "Sir", :age => (n * 10), :aliases => ["D", "Durran"], :ssn => "#{n}")
55
+ context "without results" do
56
+ it "should return nil" do
57
+ Person.max(:age).should == nil
58
58
  end
59
59
  end
60
60
 
61
- it "provides max for the field provided" do
62
- Person.max(:age).should == 90.0
63
- end
61
+ context "with results" do
62
+ before do
63
+ 10.times do |n|
64
+ Person.create(:title => "Sir", :age => (n * 10), :aliases => ["D", "Durran"], :ssn => "#{n}")
65
+ end
66
+ end
64
67
 
68
+ it "provides max for the field provided" do
69
+ Person.max(:age).should == 90.0
70
+ end
71
+ end
65
72
  end
66
73
 
67
74
  describe "#min" do
68
75
 
69
- before do
70
- 10.times do |n|
71
- Person.create(:title => "Sir", :age => ((n + 1) * 10), :aliases => ["D", "Durran"], :ssn => "#{n}")
76
+ context "without results" do
77
+ it "should return nil" do
78
+ Person.min(:age).should == nil
72
79
  end
73
80
  end
74
81
 
75
- it "provides min for the field provided" do
76
- Person.min(:age).should == 10.0
77
- end
82
+ context "with results" do
83
+ before do
84
+ 10.times do |n|
85
+ Person.create(:title => "Sir", :age => ((n + 1) * 10), :aliases => ["D", "Durran"], :ssn => "#{n}")
86
+ end
87
+ end
78
88
 
89
+ it "provides min for the field provided" do
90
+ Person.min(:age).should == 10.0
91
+ end
92
+ end
79
93
  end
80
94
 
81
95
  describe "#sum" do
82
96
 
83
- before do
84
- 10.times do |n|
85
- Person.create(:title => "Sir", :age => 5, :aliases => ["D", "Durran"], :ssn => "#{n}")
97
+ context "without results" do
98
+ it "should return nil" do
99
+ Person.sum(:age).should == nil
86
100
  end
87
101
  end
88
102
 
89
- it "provides sum for the field provided" do
90
- Person.where(:age.gt => 3).sum(:age).should == 50.0
91
- end
103
+ context "with results" do
104
+ before do
105
+ 10.times do |n|
106
+ Person.create(:title => "Sir", :age => 5, :aliases => ["D", "Durran"], :ssn => "#{n}")
107
+ end
108
+ end
92
109
 
110
+ it "provides sum for the field provided" do
111
+ Person.where(:age.gt => 3).sum(:age).should == 50.0
112
+ end
113
+ end
93
114
  end
94
115
 
95
116
  describe "#where" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Durran Jordan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-09 00:00:00 -05:00
12
+ date: 2010-02-10 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency