mongo_mapper 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/UPGRADES +6 -0
- data/lib/mongo_mapper.rb +1 -2
- data/lib/mongo_mapper/document.rb +0 -1
- data/lib/mongo_mapper/embedded_document.rb +0 -1
- data/lib/mongo_mapper/extensions/float.rb +1 -1
- data/lib/mongo_mapper/plugins.rb +2 -8
- data/lib/mongo_mapper/plugins/associations/belongs_to_association.rb +2 -0
- data/lib/mongo_mapper/plugins/associations/many_association.rb +4 -4
- data/lib/mongo_mapper/plugins/associations/many_documents_proxy.rb +9 -1
- data/lib/mongo_mapper/plugins/associations/one_as_proxy.rb +22 -0
- data/lib/mongo_mapper/plugins/associations/one_association.rb +29 -1
- data/lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb +0 -1
- data/lib/mongo_mapper/plugins/associations/one_proxy.rb +43 -16
- data/lib/mongo_mapper/plugins/clone.rb +1 -1
- data/lib/mongo_mapper/plugins/dirty.rb +6 -15
- data/lib/mongo_mapper/plugins/document.rb +5 -5
- data/lib/mongo_mapper/plugins/embedded_callbacks.rb +3 -3
- data/lib/mongo_mapper/plugins/keys.rb +0 -19
- data/lib/mongo_mapper/plugins/keys/key.rb +0 -4
- data/lib/mongo_mapper/railtie.rb +1 -2
- data/lib/mongo_mapper/version.rb +1 -1
- data/test/functional/associations/test_belongs_to_proxy.rb +15 -0
- data/test/functional/associations/test_many_documents_proxy.rb +161 -0
- data/test/functional/associations/test_one_as_proxy.rb +485 -0
- data/test/functional/associations/test_one_proxy.rb +188 -27
- data/test/functional/test_dirty.rb +9 -0
- data/test/functional/test_document.rb +5 -0
- data/test/support/railtie.rb +4 -0
- data/test/support/railtie/autoloaded.rb +2 -0
- data/test/support/railtie/not_autoloaded.rb +3 -0
- data/test/support/railtie/parent.rb +3 -0
- data/test/unit/associations/test_one_association.rb +18 -0
- data/test/unit/test_extensions.rb +4 -0
- data/test/unit/test_keys.rb +0 -22
- data/test/unit/test_plugins.rb +1 -46
- data/test/unit/test_railtie.rb +61 -0
- metadata +18 -14
- data/lib/mongo_mapper/support/descendant_appends.rb +0 -45
- data/test/functional/test_string_id_compatibility.rb +0 -75
- data/test/unit/test_descendant_appends.rb +0 -63
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 55
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 10
|
9
|
+
- 0
|
10
|
+
version: 0.10.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Nunemaker
|
@@ -15,13 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-11-02 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: activemodel
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
23
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
24
|
none: false
|
27
25
|
requirements:
|
@@ -32,11 +30,11 @@ dependencies:
|
|
32
30
|
- 3
|
33
31
|
- 0
|
34
32
|
version: "3.0"
|
33
|
+
prerelease: false
|
34
|
+
type: :runtime
|
35
35
|
requirement: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: activesupport
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
38
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
40
|
requirements:
|
@@ -47,11 +45,11 @@ dependencies:
|
|
47
45
|
- 3
|
48
46
|
- 0
|
49
47
|
version: "3.0"
|
48
|
+
prerelease: false
|
49
|
+
type: :runtime
|
50
50
|
requirement: *id002
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
52
|
name: plucky
|
53
|
-
type: :runtime
|
54
|
-
prerelease: false
|
55
53
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
56
54
|
none: false
|
57
55
|
requirements:
|
@@ -63,6 +61,8 @@ dependencies:
|
|
63
61
|
- 3
|
64
62
|
- 8
|
65
63
|
version: 0.3.8
|
64
|
+
prerelease: false
|
65
|
+
type: :runtime
|
66
66
|
requirement: *id003
|
67
67
|
description:
|
68
68
|
email:
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb
|
124
124
|
- lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb
|
125
125
|
- lib/mongo_mapper/plugins/associations/many_polymorphic_proxy.rb
|
126
|
+
- lib/mongo_mapper/plugins/associations/one_as_proxy.rb
|
126
127
|
- lib/mongo_mapper/plugins/associations/one_association.rb
|
127
128
|
- lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb
|
128
129
|
- lib/mongo_mapper/plugins/associations/one_proxy.rb
|
@@ -162,7 +163,6 @@ files:
|
|
162
163
|
- lib/mongo_mapper/plugins.rb
|
163
164
|
- lib/mongo_mapper/railtie/database.rake
|
164
165
|
- lib/mongo_mapper/railtie.rb
|
165
|
-
- lib/mongo_mapper/support/descendant_appends.rb
|
166
166
|
- lib/mongo_mapper/translation.rb
|
167
167
|
- lib/mongo_mapper/version.rb
|
168
168
|
- lib/mongo_mapper.rb
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- test/functional/associations/test_many_embedded_polymorphic_proxy.rb
|
180
180
|
- test/functional/associations/test_many_embedded_proxy.rb
|
181
181
|
- test/functional/associations/test_many_polymorphic_proxy.rb
|
182
|
+
- test/functional/associations/test_one_as_proxy.rb
|
182
183
|
- test/functional/associations/test_one_embedded_proxy.rb
|
183
184
|
- test/functional/associations/test_one_proxy.rb
|
184
185
|
- test/functional/test_accessible.rb
|
@@ -201,11 +202,14 @@ files:
|
|
201
202
|
- test/functional/test_safe.rb
|
202
203
|
- test/functional/test_sci.rb
|
203
204
|
- test/functional/test_scopes.rb
|
204
|
-
- test/functional/test_string_id_compatibility.rb
|
205
205
|
- test/functional/test_timestamps.rb
|
206
206
|
- test/functional/test_userstamps.rb
|
207
207
|
- test/functional/test_validations.rb
|
208
208
|
- test/models.rb
|
209
|
+
- test/support/railtie/autoloaded.rb
|
210
|
+
- test/support/railtie/not_autoloaded.rb
|
211
|
+
- test/support/railtie/parent.rb
|
212
|
+
- test/support/railtie.rb
|
209
213
|
- test/test_active_model_lint.rb
|
210
214
|
- test/test_helper.rb
|
211
215
|
- test/unit/associations/test_base.rb
|
@@ -216,7 +220,6 @@ files:
|
|
216
220
|
- test/unit/serializers/test_json_serializer.rb
|
217
221
|
- test/unit/serializers/test_xml_serializer.rb
|
218
222
|
- test/unit/test_clone.rb
|
219
|
-
- test/unit/test_descendant_appends.rb
|
220
223
|
- test/unit/test_document.rb
|
221
224
|
- test/unit/test_dynamic_finder.rb
|
222
225
|
- test/unit/test_embedded_document.rb
|
@@ -231,6 +234,7 @@ files:
|
|
231
234
|
- test/unit/test_plugins.rb
|
232
235
|
- test/unit/test_rails.rb
|
233
236
|
- test/unit/test_rails_compatibility.rb
|
237
|
+
- test/unit/test_railtie.rb
|
234
238
|
- test/unit/test_serialization.rb
|
235
239
|
- test/unit/test_time_zones.rb
|
236
240
|
- test/unit/test_translation.rb
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'set'
|
3
|
-
|
4
|
-
module MongoMapper
|
5
|
-
module Support
|
6
|
-
module DescendantAppends
|
7
|
-
def included(model = nil, &block)
|
8
|
-
if model
|
9
|
-
extra_extensions.each { |extension| model.extend(extension) }
|
10
|
-
extra_inclusions.each { |inclusion| model.send(:include, inclusion) }
|
11
|
-
direct_descendants << model
|
12
|
-
end
|
13
|
-
super
|
14
|
-
end
|
15
|
-
|
16
|
-
# @api public
|
17
|
-
def append_extensions(*extensions)
|
18
|
-
warn "[DEPRECATED] append_extensions is deprecated. Use #plugin with a module that extends ActiveSupport::Concern."
|
19
|
-
extra_extensions.concat(extensions)
|
20
|
-
direct_descendants.each do |model|
|
21
|
-
extensions.each { |extension| model.extend(extension) }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# @api public
|
26
|
-
def append_inclusions(*inclusions)
|
27
|
-
warn "[DEPRECATED] append_inclusions is deprecated. Use #plugin with a module that extends ActiveSupport::Concern."
|
28
|
-
extra_inclusions.concat(inclusions)
|
29
|
-
direct_descendants.each do |model|
|
30
|
-
inclusions.each { |inclusion| model.send(:include, inclusion) }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# @api private
|
35
|
-
def extra_extensions
|
36
|
-
@extra_extensions ||= []
|
37
|
-
end
|
38
|
-
|
39
|
-
# @api private
|
40
|
-
def extra_inclusions
|
41
|
-
@extra_inclusions ||= []
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class StringIdCompatibilityTest < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@note_class = EDoc do
|
6
|
-
key :_id, String
|
7
|
-
end
|
8
|
-
|
9
|
-
@task_class = Doc do
|
10
|
-
key :_id, String
|
11
|
-
key :project_id, String
|
12
|
-
belongs_to :project
|
13
|
-
end
|
14
|
-
|
15
|
-
@project_class = Doc do
|
16
|
-
include MongoMapper::Document
|
17
|
-
key :_id, String
|
18
|
-
end
|
19
|
-
|
20
|
-
@task_class.belongs_to :project, :class => @project_class
|
21
|
-
@project_class.many :notes, :class => @note_class
|
22
|
-
@project_class.many :tasks, :class => @task_class, :foreign_key => 'project_id', :order => :position.asc
|
23
|
-
end
|
24
|
-
|
25
|
-
should "assign correct _id for documents" do
|
26
|
-
project = silence_stderr { @project_class.create }
|
27
|
-
project._id.should == project.id
|
28
|
-
project._id.should be_instance_of(String)
|
29
|
-
project.id.size.should == 24
|
30
|
-
lambda {
|
31
|
-
BSON::ObjectId.from_string(project.id)
|
32
|
-
}.should_not raise_error
|
33
|
-
end
|
34
|
-
|
35
|
-
should "assign correct _id for embedded documents" do
|
36
|
-
silence_stderr do
|
37
|
-
note = @note_class.new
|
38
|
-
note.id.should == note._id
|
39
|
-
note.id.size.should == 24
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
should "find records" do
|
44
|
-
silence_stderr do
|
45
|
-
project = @project_class.create
|
46
|
-
@project_class.find(project.id).should == project
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
should "save embedded docs" do
|
51
|
-
silence_stderr do
|
52
|
-
n1 = @note_class.new
|
53
|
-
n2 = @note_class.new
|
54
|
-
n3 = @note_class.new
|
55
|
-
project = @project_class.create(:notes => [n1, n2, n3])
|
56
|
-
|
57
|
-
project = project.reload
|
58
|
-
project.notes.size.should == 3
|
59
|
-
project.notes.should == [n1, n2, n3]
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
should "be able to associate records" do
|
64
|
-
silence_stderr do
|
65
|
-
t1 = @task_class.new(:body => 'First task', :position => 1)
|
66
|
-
t2 = @task_class.new(:body => 'Second task', :position => 2)
|
67
|
-
t3 = @task_class.new(:body => 'Third task', :position => 3)
|
68
|
-
project = @project_class.create(:name => 'MM', :tasks => [t1, t2, t3])
|
69
|
-
|
70
|
-
project = project.reload
|
71
|
-
project.tasks.count.should == 3
|
72
|
-
project.tasks.should == [t1, t2, t3]
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class DescendantAppendsTest < Test::Unit::TestCase
|
4
|
-
context "Document" do
|
5
|
-
should 'allow extensions to Document to be appended' do
|
6
|
-
module Extension; def test_this_extension; end end
|
7
|
-
silence_stderr { MongoMapper::Document.append_extensions(Extension) }
|
8
|
-
article = Doc()
|
9
|
-
article.should respond_to(:test_this_extension)
|
10
|
-
end
|
11
|
-
|
12
|
-
should 'add appended extensions to classes that include Document before they are added' do
|
13
|
-
module Extension; def test_this_extension; end end
|
14
|
-
article = Doc()
|
15
|
-
silence_stderr { MongoMapper::Document.append_extensions(Extension) }
|
16
|
-
article.should respond_to(:test_this_extension)
|
17
|
-
end
|
18
|
-
|
19
|
-
should 'allow inclusions to Document to be appended' do
|
20
|
-
module Inclusion; def test_this_inclusion; end end
|
21
|
-
silence_stderr { MongoMapper::Document.append_inclusions(Inclusion) }
|
22
|
-
article = Doc()
|
23
|
-
article.new.should respond_to(:test_this_inclusion)
|
24
|
-
end
|
25
|
-
|
26
|
-
should 'add appended inclusions to classes that include Document before they are added' do
|
27
|
-
module Inclusion; def test_this_inclusion; end end
|
28
|
-
article = Doc()
|
29
|
-
silence_stderr { MongoMapper::Document.append_inclusions(Inclusion) }
|
30
|
-
article.new.should respond_to(:test_this_inclusion)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "EmbeddedDocument" do
|
35
|
-
should 'allow extensions to Document to be appended' do
|
36
|
-
module Extension; def test_this_extension; end end
|
37
|
-
silence_stderr { MongoMapper::EmbeddedDocument.append_extensions(Extension) }
|
38
|
-
article = EDoc()
|
39
|
-
article.should respond_to(:test_this_extension)
|
40
|
-
end
|
41
|
-
|
42
|
-
should 'add appended extensions to classes that include Document before they are added' do
|
43
|
-
module Extension; def test_this_extension; end end
|
44
|
-
article = EDoc()
|
45
|
-
silence_stderr { MongoMapper::EmbeddedDocument.append_extensions(Extension) }
|
46
|
-
article.should respond_to(:test_this_extension)
|
47
|
-
end
|
48
|
-
|
49
|
-
should 'allow inclusions to Document to be appended' do
|
50
|
-
module Inclusion; def test_this_inclusion; end end
|
51
|
-
silence_stderr { MongoMapper::EmbeddedDocument.append_inclusions(Inclusion) }
|
52
|
-
article = EDoc()
|
53
|
-
article.new.should respond_to(:test_this_inclusion)
|
54
|
-
end
|
55
|
-
|
56
|
-
should 'add appended inclusions to classes that include Document before they are added' do
|
57
|
-
module Inclusion; def test_this_inclusion; end end
|
58
|
-
article = EDoc()
|
59
|
-
silence_stderr { MongoMapper::EmbeddedDocument.append_inclusions(Inclusion) }
|
60
|
-
article.new.should respond_to(:test_this_inclusion)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|