mongo_mapper 0.6.5 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.5
1
+ 0.6.6
@@ -469,7 +469,7 @@ module MongoMapper
469
469
 
470
470
  def update_timestamps
471
471
  now = Time.now.utc
472
- write_attribute('created_at', now) if new?
472
+ write_attribute('created_at', now) if new? && read_attribute('created_at').blank?
473
473
  write_attribute('updated_at', now)
474
474
  end
475
475
 
@@ -333,6 +333,11 @@ module MongoMapper
333
333
  save
334
334
  end
335
335
 
336
+ def update_attributes!(attrs={})
337
+ self.attributes = attrs
338
+ save!
339
+ end
340
+
336
341
  private
337
342
  def _keys
338
343
  self.metaclass.keys
@@ -188,6 +188,6 @@ end
188
188
  # TODO: Remove when patch accepted into driver
189
189
  class Mongo::ObjectID
190
190
  def to_json(options = nil)
191
- to_s
191
+ %Q("#{to_s}")
192
192
  end
193
193
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongo_mapper}
8
- s.version = "0.6.5"
8
+ s.version = "0.6.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Nunemaker"]
12
- s.date = %q{2009-12-01}
12
+ s.date = %q{2009-12-05}
13
13
  s.default_executable = %q{mmconsole}
14
14
  s.email = %q{nunemaker@gmail.com}
15
15
  s.executables = ["mmconsole"]
@@ -1113,6 +1113,16 @@ class DocumentTest < Test::Unit::TestCase
1113
1113
  doc.created_at.should_not be(nil)
1114
1114
  doc.updated_at.should_not be(nil)
1115
1115
  end
1116
+
1117
+ should "not overwrite created_at if it already exists" do
1118
+ original_created_at = 1.month.ago
1119
+ doc = @document.new(:first_name => 'John', :age => 27, :created_at => original_created_at)
1120
+ doc.created_at.to_i.should == original_created_at.to_i
1121
+ doc.updated_at.should be_nil
1122
+ doc.save
1123
+ doc.created_at.to_i.should == original_created_at.to_i
1124
+ doc.updated_at.should_not be_nil
1125
+ end
1116
1126
 
1117
1127
  should "set updated_at on field update but leave created_at alone" do
1118
1128
  doc = @document.create(:first_name => 'John', :age => 27)
@@ -122,4 +122,14 @@ class EmbeddedDocumentTest < Test::Unit::TestCase
122
122
  person.pets.first.name.should == 'koda'
123
123
  end
124
124
  end
125
+
126
+ context "update_attributes!" do
127
+ should "pass the attributes to self.attributes" do
128
+ person = RealPerson.create
129
+ attributes = { :foo => 'bar' }
130
+ person.expects(:attributes=).with(attributes)
131
+ person.expects(:save!)
132
+ person.update_attributes!(attributes)
133
+ end
134
+ end
125
135
  end
@@ -335,7 +335,7 @@ class SupportTest < Test::Unit::TestCase
335
335
  context "Mongo::ObjectID.to_json" do
336
336
  should "convert object id to string" do
337
337
  id = Mongo::ObjectID.new
338
- id.to_json.should == id.to_s
338
+ id.to_json.should == %Q("#{id}")
339
339
  end
340
340
  end
341
341
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_mapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-01 00:00:00 -05:00
12
+ date: 2009-12-05 00:00:00 -05:00
13
13
  default_executable: mmconsole
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency