mongoid 0.10.2 → 0.10.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ begin
15
15
  gem.add_dependency("activesupport", ">= 2.2.2")
16
16
  gem.add_dependency("mongo", ">= 0.18.1")
17
17
  gem.add_dependency("mongo_ext", ">= 0.18.1")
18
- gem.add_dependency("durran-validatable", ">= 1.8.3")
18
+ gem.add_dependency("durran-validatable", ">= 1.8.4")
19
19
  gem.add_dependency("leshill-will_paginate", ">= 2.3.11")
20
20
 
21
21
  gem.add_development_dependency("rspec", ">= 1.2.9")
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.2
1
+ 0.10.3
@@ -24,7 +24,7 @@ require "rubygems"
24
24
  gem "activesupport", ">= 2.2.2"
25
25
  gem "mongo", ">= 0.18.1"
26
26
  gem "mongo_ext", ">= 0.18.1"
27
- gem "durran-validatable", ">= 1.8.3"
27
+ gem "durran-validatable", ">= 1.8.4"
28
28
  gem "leshill-will_paginate", ">= 2.3.11"
29
29
 
30
30
  require "delegate"
@@ -192,7 +192,8 @@ module Mongoid #:nodoc:
192
192
 
193
193
  # Returns the class name plus its attributes.
194
194
  def inspect
195
- "#{self.class.name} : #{@attributes.inspect}"
195
+ attrs = fields.map { |name, field| "#{name}: #{@attributes[name] || 'nil'}" } * ", "
196
+ "#<#{self.class.name} _id: #{id}, #{attrs}>"
196
197
  end
197
198
 
198
199
  # Returns true is the +Document+ has not been persisted to the database,
@@ -248,6 +249,11 @@ module Mongoid #:nodoc:
248
249
  object || self
249
250
  end
250
251
 
252
+ # Return an array with this +Document+ only in it.
253
+ def to_a
254
+ [ self ]
255
+ end
256
+
251
257
  # Returns the id of the Document, used in Rails compatibility.
252
258
  def to_param
253
259
  id
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid}
8
- s.version = "0.10.2"
8
+ s.version = "0.10.3"
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{2009-12-25}
12
+ s.date = %q{2009-12-26}
13
13
  s.email = %q{durran@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.textile"
@@ -184,7 +184,7 @@ Gem::Specification.new do |s|
184
184
  s.add_runtime_dependency(%q<activesupport>, [">= 2.2.2"])
185
185
  s.add_runtime_dependency(%q<mongo>, [">= 0.18.1"])
186
186
  s.add_runtime_dependency(%q<mongo_ext>, [">= 0.18.1"])
187
- s.add_runtime_dependency(%q<durran-validatable>, [">= 1.8.3"])
187
+ s.add_runtime_dependency(%q<durran-validatable>, [">= 1.8.4"])
188
188
  s.add_runtime_dependency(%q<leshill-will_paginate>, [">= 2.3.11"])
189
189
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
190
190
  s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
@@ -192,7 +192,7 @@ Gem::Specification.new do |s|
192
192
  s.add_dependency(%q<activesupport>, [">= 2.2.2"])
193
193
  s.add_dependency(%q<mongo>, [">= 0.18.1"])
194
194
  s.add_dependency(%q<mongo_ext>, [">= 0.18.1"])
195
- s.add_dependency(%q<durran-validatable>, [">= 1.8.3"])
195
+ s.add_dependency(%q<durran-validatable>, [">= 1.8.4"])
196
196
  s.add_dependency(%q<leshill-will_paginate>, [">= 2.3.11"])
197
197
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
198
198
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
@@ -201,7 +201,7 @@ Gem::Specification.new do |s|
201
201
  s.add_dependency(%q<activesupport>, [">= 2.2.2"])
202
202
  s.add_dependency(%q<mongo>, [">= 0.18.1"])
203
203
  s.add_dependency(%q<mongo_ext>, [">= 0.18.1"])
204
- s.add_dependency(%q<durran-validatable>, [">= 1.8.3"])
204
+ s.add_dependency(%q<durran-validatable>, [">= 1.8.4"])
205
205
  s.add_dependency(%q<leshill-will_paginate>, [">= 2.3.11"])
206
206
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
207
207
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
@@ -174,6 +174,35 @@ describe Mongoid::Document do
174
174
 
175
175
  end
176
176
 
177
+ context "when address is a has one" do
178
+
179
+ before do
180
+ @owner = PetOwner.create(:title => "AKC")
181
+ @address = Address.new(:street => "Fido Street")
182
+ @owner.address = @address
183
+ @owner.save
184
+ end
185
+
186
+ it "is a single object and not an array" do
187
+ @from_db = PetOwner.find(@owner.id)
188
+ @from_db.address.should == @address
189
+ end
190
+
191
+ end
192
+
193
+ describe "#inspect" do
194
+
195
+ before do
196
+ @person = Person.new
197
+ end
198
+
199
+ it "returns a pretty string of class name and attributes" do
200
+ attrs = Person.fields.map { |name, field| "#{name}: #{@person.attributes[name] || 'nil'}" } * ", "
201
+ @person.inspect.should == "#<Person _id: #{@person.id}, #{attrs}>"
202
+ end
203
+
204
+ end
205
+
177
206
  describe "#paginate" do
178
207
 
179
208
  before do
@@ -239,6 +239,10 @@ describe Mongoid::Criteria do
239
239
 
240
240
  end
241
241
 
242
+ describe "#each_index" do
243
+
244
+ end
245
+
242
246
  describe "#excludes" do
243
247
 
244
248
  it "adds the $ne query to the selector" do
@@ -527,6 +527,15 @@ describe Mongoid::Document do
527
527
 
528
528
  end
529
529
 
530
+ describe "#to_a" do
531
+
532
+ it "returns an array with the document in it" do
533
+ person = Person.new
534
+ person.to_a.should == [ person ]
535
+ end
536
+
537
+ end
538
+
530
539
  describe "#to_param" do
531
540
 
532
541
  it "returns the id" 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: 0.10.2
4
+ version: 0.10.3
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: 2009-12-25 00:00:00 -05:00
12
+ date: 2009-12-26 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 1.8.3
53
+ version: 1.8.4
54
54
  version:
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: leshill-will_paginate