mongo_mapper 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/mongo_mapper/document.rb +1 -1
- data/lib/mongo_mapper/embedded_document.rb +5 -0
- data/lib/mongo_mapper/support.rb +1 -1
- data/mongo_mapper.gemspec +2 -2
- data/test/functional/test_document.rb +10 -0
- data/test/functional/test_embedded_document.rb +10 -0
- data/test/unit/test_support.rb +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
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
|
|
data/lib/mongo_mapper/support.rb
CHANGED
data/mongo_mapper.gemspec
CHANGED
@@ -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.
|
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-
|
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
|
data/test/unit/test_support.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2009-12-05 00:00:00 -05:00
|
13
13
|
default_executable: mmconsole
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|