mongo_mapper-unstable 2010.2.19 → 2010.2.22
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -0
- data/VERSION +1 -1
- data/lib/mongo_mapper/plugins/associations/in_array_proxy.rb +2 -0
- data/lib/mongo_mapper/plugins/associations/many_documents_proxy.rb +3 -0
- data/lib/mongo_mapper/plugins/protected.rb +1 -1
- data/test/functional/associations/test_in_array_proxy.rb +12 -0
- data/test/functional/associations/test_many_documents_proxy.rb +22 -0
- data/test/functional/test_protected.rb +11 -5
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -24,6 +24,8 @@ http://groups.google.com/group/mongomapper
|
|
24
24
|
To see if the problem you are having is a verified issue, you can see the MM pivotal tracker project:
|
25
25
|
http://www.pivotaltracker.com/projects/33576
|
26
26
|
|
27
|
+
There is no need to request to join the Pivotal Tracker project as I am only granting access to a select few (easier to keep things organized). If you have a problem, please use the mailing list. If I confirm it to be a bug, I am happy to add it to PT. Thanks!
|
28
|
+
|
27
29
|
== Copyright
|
28
30
|
|
29
31
|
Copyright (c) 2009 John Nunemaker. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2010.02.
|
1
|
+
2010.02.22
|
@@ -52,18 +52,21 @@ module MongoMapper
|
|
52
52
|
def build(attrs={})
|
53
53
|
doc = klass.new(attrs)
|
54
54
|
apply_scope(doc)
|
55
|
+
reset
|
55
56
|
doc
|
56
57
|
end
|
57
58
|
|
58
59
|
def create(attrs={})
|
59
60
|
doc = klass.new(attrs)
|
60
61
|
apply_scope(doc).save
|
62
|
+
reset
|
61
63
|
doc
|
62
64
|
end
|
63
65
|
|
64
66
|
def create!(attrs={})
|
65
67
|
doc = klass.new(attrs)
|
66
68
|
apply_scope(doc).save!
|
69
|
+
reset
|
67
70
|
doc
|
68
71
|
end
|
69
72
|
|
@@ -37,7 +37,7 @@ module MongoMapper
|
|
37
37
|
protected
|
38
38
|
def filter_protected_attrs(attrs)
|
39
39
|
return attrs if protected_attributes.blank?
|
40
|
-
attrs.dup.delete_if { |key, val| protected_attributes.include?(key) }
|
40
|
+
attrs.dup.delete_if { |key, val| protected_attributes.include?(key.to_sym) }
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -80,6 +80,12 @@ class InArrayProxyTest < Test::Unit::TestCase
|
|
80
80
|
should "save doc" do
|
81
81
|
@list.should_not be_new
|
82
82
|
end
|
83
|
+
|
84
|
+
should "reset cache" do
|
85
|
+
@user.lists.size.should == 1
|
86
|
+
@user.lists.create(:name => 'Moo!')
|
87
|
+
@user.lists.size.should == 2
|
88
|
+
end
|
83
89
|
end
|
84
90
|
|
85
91
|
context "create!" do
|
@@ -110,6 +116,12 @@ class InArrayProxyTest < Test::Unit::TestCase
|
|
110
116
|
@user.lists.create!
|
111
117
|
end
|
112
118
|
end
|
119
|
+
|
120
|
+
should "reset cache" do
|
121
|
+
@user.lists.size.should == 1
|
122
|
+
@user.lists.create!(:name => 'Moo!')
|
123
|
+
@user.lists.size.should == 2
|
124
|
+
end
|
113
125
|
end
|
114
126
|
|
115
127
|
context "Finding scoped to association" do
|
@@ -54,6 +54,14 @@ class ManyDocumentsProxyTest < Test::Unit::TestCase
|
|
54
54
|
status = project.statuses.build(:name => 'Foo')
|
55
55
|
status.name.should == 'Foo'
|
56
56
|
end
|
57
|
+
|
58
|
+
should "reset cache" do
|
59
|
+
project = Project.create
|
60
|
+
project.statuses.size.should == 0
|
61
|
+
status = project.statuses.build(:name => 'Foo')
|
62
|
+
status.save!
|
63
|
+
project.statuses.size.should == 1
|
64
|
+
end
|
57
65
|
end
|
58
66
|
|
59
67
|
context "create" do
|
@@ -75,6 +83,13 @@ class ManyDocumentsProxyTest < Test::Unit::TestCase
|
|
75
83
|
status = project.statuses.create(:name => 'Foo!')
|
76
84
|
status.name.should == 'Foo!'
|
77
85
|
end
|
86
|
+
|
87
|
+
should "reset cache" do
|
88
|
+
project = Project.create
|
89
|
+
project.statuses.size.should == 0
|
90
|
+
project.statuses.create(:name => 'Foo!')
|
91
|
+
project.statuses.size.should == 1
|
92
|
+
end
|
78
93
|
end
|
79
94
|
|
80
95
|
context "create!" do
|
@@ -103,6 +118,13 @@ class ManyDocumentsProxyTest < Test::Unit::TestCase
|
|
103
118
|
project.statuses.create!(:name => nil)
|
104
119
|
}.should raise_error(MongoMapper::DocumentNotValid)
|
105
120
|
end
|
121
|
+
|
122
|
+
should "reset cache" do
|
123
|
+
project = Project.create
|
124
|
+
project.statuses.size.should == 0
|
125
|
+
project.statuses.create!(:name => 'Foo!')
|
126
|
+
project.statuses.size.should == 1
|
127
|
+
end
|
106
128
|
end
|
107
129
|
|
108
130
|
context "count" do
|
@@ -16,7 +16,7 @@ class ProtectedTest < Test::Unit::TestCase
|
|
16
16
|
should 'have protected attributes class method' do
|
17
17
|
@doc_class.protected_attributes.should == [:admin].to_set
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
should "default protected attributes to nil" do
|
21
21
|
Doc().protected_attributes.should be_nil
|
22
22
|
end
|
@@ -46,7 +46,7 @@ class ProtectedTest < Test::Unit::TestCase
|
|
46
46
|
doc = @doc_class.new(:name => 'John')
|
47
47
|
doc.admin = true
|
48
48
|
doc.save!
|
49
|
-
|
49
|
+
|
50
50
|
doc = @doc_class.first(:name => 'John')
|
51
51
|
doc.admin.should be_true
|
52
52
|
doc.name.should == 'John'
|
@@ -63,8 +63,14 @@ class ProtectedTest < Test::Unit::TestCase
|
|
63
63
|
@doc.name.should == 'Stimpson J. Cat'
|
64
64
|
@doc.admin.should be_false
|
65
65
|
end
|
66
|
+
|
67
|
+
should 'be indifferent to whether the protected keys are strings or symbols' do
|
68
|
+
@doc.update_attributes!("name" => 'Stimpson J. Cat', "admin" => true)
|
69
|
+
@doc.name.should == 'Stimpson J. Cat'
|
70
|
+
@doc.admin.should be_false
|
71
|
+
end
|
66
72
|
end
|
67
|
-
|
73
|
+
|
68
74
|
context "Single collection inherited protected attributes" do
|
69
75
|
setup do
|
70
76
|
class ::GrandParent
|
@@ -126,7 +132,7 @@ class ProtectedTest < Test::Unit::TestCase
|
|
126
132
|
should 'have protected attributes class method' do
|
127
133
|
@edoc_class.protected_attributes.should == [:admin].to_set
|
128
134
|
end
|
129
|
-
|
135
|
+
|
130
136
|
should "default protected attributes to nil" do
|
131
137
|
EDoc().protected_attributes.should be_nil
|
132
138
|
end
|
@@ -152,4 +158,4 @@ class ProtectedTest < Test::Unit::TestCase
|
|
152
158
|
@edoc.admin.should be_false
|
153
159
|
end
|
154
160
|
end
|
155
|
-
end
|
161
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_mapper-unstable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2010.2.
|
4
|
+
version: 2010.2.22
|
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: 2010-02-
|
12
|
+
date: 2010-02-22 00:00:00 -05:00
|
13
13
|
default_executable: mmconsole
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|