djsun-mongomapper 0.3.5.4 → 0.3.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/mongomapper/embedded_document.rb +6 -1
- data/mongomapper.gemspec +1 -1
- data/test/unit/serializers/test_json_serializer.rb +5 -1
- data/test/unit/test_embedded_document.rb +3 -3
- metadata +1 -1
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ begin
|
|
12
12
|
gem.rubyforge_project = "mongomapper"
|
13
13
|
|
14
14
|
gem.add_dependency('activesupport')
|
15
|
-
gem.add_dependency('mongodb-mongo', '0.14')
|
15
|
+
gem.add_dependency('mongodb-mongo', '0.14.1')
|
16
16
|
gem.add_dependency('jnunemaker-validatable', '1.7.2')
|
17
17
|
|
18
18
|
gem.add_development_dependency('mocha', '0.9.4')
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.5
|
1
|
+
0.3.5.5
|
@@ -196,10 +196,15 @@ module MongoMapper
|
|
196
196
|
end
|
197
197
|
end
|
198
198
|
|
199
|
-
attrs[name] = value
|
199
|
+
attrs[name] = value
|
200
200
|
end
|
201
201
|
attrs.merge!(embedded_association_attributes)
|
202
202
|
end
|
203
|
+
|
204
|
+
# all attributes, even ones with null values
|
205
|
+
def all_attributes
|
206
|
+
|
207
|
+
end
|
203
208
|
|
204
209
|
def [](name)
|
205
210
|
read_attribute(name)
|
data/mongomapper.gemspec
CHANGED
@@ -13,6 +13,7 @@ class JsonSerializationTest < Test::Unit::TestCase
|
|
13
13
|
key :created_at, Time
|
14
14
|
key :awesome, Boolean
|
15
15
|
key :preferences, Hash
|
16
|
+
key :hiding, String
|
16
17
|
|
17
18
|
many :tags, :class_name => 'JsonSerializationTest::Tag'
|
18
19
|
end
|
@@ -42,6 +43,7 @@ class JsonSerializationTest < Test::Unit::TestCase
|
|
42
43
|
assert json.include?(%("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}))
|
43
44
|
assert_match %r{"awesome":true}, json
|
44
45
|
assert_match %r{"preferences":\{"shows":"anime"\}}, json
|
46
|
+
assert_match %r{"hiding":null}, json
|
45
47
|
end
|
46
48
|
|
47
49
|
should "allow attribute filtering with only" do
|
@@ -53,6 +55,7 @@ class JsonSerializationTest < Test::Unit::TestCase
|
|
53
55
|
assert_no_match %r{"awesome"}, json
|
54
56
|
assert_no_match %r{"created_at"}, json
|
55
57
|
assert_no_match %r{"preferences"}, json
|
58
|
+
assert_no_match %r{"hiding"}, json
|
56
59
|
end
|
57
60
|
|
58
61
|
should "allow attribute filtering with except" do
|
@@ -64,6 +67,7 @@ class JsonSerializationTest < Test::Unit::TestCase
|
|
64
67
|
assert_match %r{"awesome"}, json
|
65
68
|
assert_match %r{"created_at"}, json
|
66
69
|
assert_match %r{"preferences"}, json
|
70
|
+
assert_match %r{"hiding"}, json
|
67
71
|
end
|
68
72
|
|
69
73
|
context "_id key" do
|
@@ -141,7 +145,7 @@ class JsonSerializationTest < Test::Unit::TestCase
|
|
141
145
|
Contact.new(:name => 'Mary', :age => 14)
|
142
146
|
]
|
143
147
|
end
|
144
|
-
|
148
|
+
|
145
149
|
should "allow attribute filtering with only" do
|
146
150
|
json = @contacts.to_json(:only => :name)
|
147
151
|
assert_match %r{\{"name":"David"\}}, json
|
@@ -342,12 +342,12 @@ class EmbeddedDocumentTest < Test::Unit::TestCase
|
|
342
342
|
context "attributes" do
|
343
343
|
should "default to hash with _id" do
|
344
344
|
doc = @document.new
|
345
|
-
doc.attributes.keys.should ==
|
345
|
+
doc.attributes.keys.sort.should == %w(_id age name)
|
346
346
|
end
|
347
347
|
|
348
|
-
should "return all keys
|
348
|
+
should "return all keys, including ones with nil values" do
|
349
349
|
doc = @document.new(:name => 'string', :age => nil)
|
350
|
-
doc.attributes.keys.sort.should ==
|
350
|
+
doc.attributes.keys.sort.should == %w(_id age name)
|
351
351
|
doc.attributes.values.should include('string')
|
352
352
|
end
|
353
353
|
end
|