mongo_mapper 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -2
- data/lib/mongo_mapper.rb +2 -3
- data/lib/mongo_mapper/plugins/associations.rb +10 -1
- data/lib/mongo_mapper/plugins/associations/base.rb +2 -2
- data/lib/mongo_mapper/plugins/associations/many_documents_proxy.rb +12 -3
- data/lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb +41 -0
- data/lib/mongo_mapper/plugins/associations/one_proxy.rb +1 -0
- data/lib/mongo_mapper/plugins/associations/proxy.rb +8 -2
- data/lib/mongo_mapper/plugins/callbacks.rb +7 -3
- data/lib/mongo_mapper/plugins/descendants.rb +2 -2
- data/lib/mongo_mapper/plugins/keys.rb +14 -7
- data/lib/mongo_mapper/plugins/modifiers.rb +30 -14
- data/lib/mongo_mapper/plugins/protected.rb +1 -1
- data/lib/mongo_mapper/plugins/serialization.rb +1 -1
- data/lib/mongo_mapper/query.rb +27 -19
- data/lib/mongo_mapper/support.rb +10 -6
- data/lib/mongo_mapper/version.rb +1 -1
- data/mongo_mapper.gemspec +14 -8
- data/test/functional/associations/test_belongs_to_polymorphic_proxy.rb +1 -1
- data/test/functional/associations/test_belongs_to_proxy.rb +1 -1
- data/test/functional/associations/test_many_documents_proxy.rb +100 -17
- data/test/functional/associations/test_one_embedded_proxy.rb +68 -0
- data/test/functional/associations/test_one_proxy.rb +48 -13
- data/test/functional/test_binary.rb +1 -1
- data/test/functional/test_document.rb +7 -7
- data/test/functional/test_embedded_document.rb +8 -0
- data/test/functional/test_identity_map.rb +2 -2
- data/test/functional/test_modifiers.rb +249 -185
- data/test/functional/test_protected.rb +4 -0
- data/test/functional/test_string_id_compatibility.rb +1 -1
- data/test/support/custom_matchers.rb +0 -18
- data/test/test_helper.rb +6 -4
- data/test/unit/associations/test_base.rb +7 -2
- data/test/unit/test_document.rb +5 -5
- data/test/unit/test_embedded_document.rb +7 -7
- data/test/unit/test_query.rb +17 -7
- data/test/unit/test_support.rb +26 -14
- metadata +33 -16
@@ -42,6 +42,14 @@ class EmbeddedDocumentTest < Test::Unit::TestCase
|
|
42
42
|
address._parent_document.should be(doc)
|
43
43
|
address._root_document.should be(doc)
|
44
44
|
end
|
45
|
+
|
46
|
+
should "assign _parent_document and _root_document when loading" do
|
47
|
+
address = @address_class.new(:city => 'South Bend', :state => 'IN')
|
48
|
+
doc = @klass.create(:foo => address)
|
49
|
+
doc.reload
|
50
|
+
doc.foo._parent_document.should be(doc)
|
51
|
+
doc.foo._root_document.should be(doc)
|
52
|
+
end
|
45
53
|
end
|
46
54
|
|
47
55
|
should "correctly instantiate single collection inherited embedded documents" do
|
@@ -142,7 +142,7 @@ class IdentityMapTest < Test::Unit::TestCase
|
|
142
142
|
|
143
143
|
context "#load" do
|
144
144
|
setup do
|
145
|
-
@id =
|
145
|
+
@id = BSON::ObjectID.new
|
146
146
|
end
|
147
147
|
|
148
148
|
should "add document to map" do
|
@@ -453,7 +453,7 @@ class IdentityMapTest < Test::Unit::TestCase
|
|
453
453
|
|
454
454
|
should "not add to map when loading" do
|
455
455
|
@post_class.without_identity_map do
|
456
|
-
post = @post_class.load({'_id' =>
|
456
|
+
post = @post_class.load({'_id' => BSON::ObjectID.new, 'title' => 'Awesome!'})
|
457
457
|
assert_not_in_map(post)
|
458
458
|
end
|
459
459
|
end
|
@@ -3,11 +3,11 @@ require 'test_helper'
|
|
3
3
|
class ModifierTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
5
|
@page_class = Doc do
|
6
|
-
key :title,
|
7
|
-
key :day_count,
|
8
|
-
key :week_count,
|
6
|
+
key :title, String
|
7
|
+
key :day_count, Integer, :default => 0
|
8
|
+
key :week_count, Integer, :default => 0
|
9
9
|
key :month_count, Integer, :default => 0
|
10
|
-
key :tags,
|
10
|
+
key :tags, Array
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -18,268 +18,321 @@ class ModifierTest < Test::Unit::TestCase
|
|
18
18
|
page.month_count.should == month_count
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@page_class.increment({:title => 'Home'}, {
|
27
|
-
:day_count => 1, :week_count => 2, :month_count => 3
|
28
|
-
})
|
29
|
-
|
30
|
-
assert_page_counts page, 1, 2, 3
|
31
|
-
assert_page_counts page2, 1, 2, 3
|
21
|
+
def assert_keys_removed(page, *keys)
|
22
|
+
keys.each do |key|
|
23
|
+
doc = @page_class.collection.find_one({:_id => page.id})
|
24
|
+
doc.keys.should_not include(key)
|
32
25
|
end
|
26
|
+
end
|
33
27
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
28
|
+
context "ClassMethods" do
|
29
|
+
context "unset" do
|
30
|
+
setup do
|
31
|
+
@page = @page_class.create(:title => 'Home', :tags => %w(foo bar))
|
32
|
+
@page2 = @page_class.create(:title => 'Home')
|
33
|
+
end
|
34
|
+
|
35
|
+
should "work with criteria and keys" do
|
36
|
+
@page_class.unset({:title => 'Home'}, :title, :tags)
|
37
|
+
assert_keys_removed @page, :title, :tags
|
38
|
+
assert_keys_removed @page2, :title, :tags
|
39
|
+
end
|
40
|
+
|
41
|
+
should "work with ids and keys" do
|
42
|
+
@page_class.unset(@page.id, @page2.id, :title, :tags)
|
43
|
+
assert_keys_removed @page, :title, :tags
|
44
|
+
assert_keys_removed @page2, :title, :tags
|
45
|
+
end
|
44
46
|
end
|
47
|
+
|
48
|
+
context "increment" do
|
49
|
+
setup do
|
50
|
+
@page = @page_class.create(:title => 'Home')
|
51
|
+
@page2 = @page_class.create(:title => 'Home')
|
52
|
+
end
|
45
53
|
|
46
|
-
|
47
|
-
|
48
|
-
page2 = @page_class.create(:title => 'Home', :day_count => 1, :week_count => 2, :month_count => 3)
|
49
|
-
|
50
|
-
@page_class.decrement({:title => 'Home'}, {
|
51
|
-
:day_count => 1, :week_count => 2, :month_count => 3
|
52
|
-
})
|
53
|
-
|
54
|
-
assert_page_counts page, 0, 0, 0
|
55
|
-
assert_page_counts page2, 0, 0, 0
|
56
|
-
end
|
54
|
+
should "work with criteria and modifier hashes" do
|
55
|
+
@page_class.increment({:title => 'Home'}, :day_count => 1, :week_count => 2, :month_count => 3)
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
assert_page_counts @page, 1, 2, 3
|
58
|
+
assert_page_counts @page2, 1, 2, 3
|
59
|
+
end
|
61
60
|
|
62
|
-
|
63
|
-
:day_count => 1, :week_count => 2, :month_count => 3
|
64
|
-
})
|
61
|
+
should "work with ids and modifier hash" do
|
62
|
+
@page_class.increment(@page.id, @page2.id, :day_count => 1, :week_count => 2, :month_count => 3)
|
65
63
|
|
66
|
-
|
67
|
-
|
64
|
+
assert_page_counts @page, 1, 2, 3
|
65
|
+
assert_page_counts @page2, 1, 2, 3
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "decrement" do
|
70
|
+
setup do
|
71
|
+
@page = @page_class.create(:title => 'Home', :day_count => 1, :week_count => 2, :month_count => 3)
|
72
|
+
@page2 = @page_class.create(:title => 'Home', :day_count => 1, :week_count => 2, :month_count => 3)
|
73
|
+
end
|
74
|
+
|
75
|
+
should "work with criteria and modifier hashes" do
|
76
|
+
@page_class.decrement({:title => 'Home'}, :day_count => 1, :week_count => 2, :month_count => 3)
|
77
|
+
|
78
|
+
assert_page_counts @page, 0, 0, 0
|
79
|
+
assert_page_counts @page2, 0, 0, 0
|
80
|
+
end
|
81
|
+
|
82
|
+
should "work with ids and modifier hash" do
|
83
|
+
@page_class.decrement(@page.id, @page2.id, :day_count => 1, :week_count => 2, :month_count => 3)
|
84
|
+
|
85
|
+
assert_page_counts @page, 0, 0, 0
|
86
|
+
assert_page_counts @page2, 0, 0, 0
|
87
|
+
end
|
88
|
+
|
89
|
+
should "decrement with positive or negative numbers" do
|
90
|
+
@page_class.decrement(@page.id, @page2.id, :day_count => -1, :week_count => 2, :month_count => -3)
|
91
|
+
|
92
|
+
assert_page_counts @page, 0, 0, 0
|
93
|
+
assert_page_counts @page2, 0, 0, 0
|
94
|
+
end
|
68
95
|
end
|
69
96
|
|
70
|
-
|
71
|
-
|
72
|
-
|
97
|
+
context "set" do
|
98
|
+
setup do
|
99
|
+
@page = @page_class.create(:title => 'Home')
|
100
|
+
@page2 = @page_class.create(:title => 'Home')
|
101
|
+
end
|
73
102
|
|
74
|
-
|
75
|
-
:
|
76
|
-
})
|
103
|
+
should "work with criteria and modifier hashes" do
|
104
|
+
@page_class.set({:title => 'Home'}, :title => 'Home Revised')
|
77
105
|
|
78
|
-
|
79
|
-
|
80
|
-
end
|
106
|
+
@page.reload
|
107
|
+
@page.title.should == 'Home Revised'
|
81
108
|
|
82
|
-
|
83
|
-
|
84
|
-
|
109
|
+
@page2.reload
|
110
|
+
@page2.title.should == 'Home Revised'
|
111
|
+
end
|
85
112
|
|
86
|
-
|
113
|
+
should "work with ids and modifier hash" do
|
114
|
+
@page_class.set(@page.id, @page2.id, :title => 'Home Revised')
|
87
115
|
|
88
|
-
|
89
|
-
|
116
|
+
@page.reload
|
117
|
+
@page.title.should == 'Home Revised'
|
90
118
|
|
91
|
-
|
92
|
-
|
119
|
+
@page2.reload
|
120
|
+
@page2.title.should == 'Home Revised'
|
121
|
+
end
|
93
122
|
end
|
94
123
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
124
|
+
context "push" do
|
125
|
+
setup do
|
126
|
+
@page = @page_class.create(:title => 'Home')
|
127
|
+
@page2 = @page_class.create(:title => 'Home')
|
128
|
+
end
|
100
129
|
|
101
|
-
|
102
|
-
|
130
|
+
should "work with criteria and modifier hashes" do
|
131
|
+
@page_class.push({:title => 'Home'}, :tags => 'foo')
|
103
132
|
|
104
|
-
|
105
|
-
|
106
|
-
end
|
133
|
+
@page.reload
|
134
|
+
@page.tags.should == %w(foo)
|
107
135
|
|
108
|
-
|
109
|
-
|
110
|
-
|
136
|
+
@page2.reload
|
137
|
+
@page.tags.should == %w(foo)
|
138
|
+
end
|
111
139
|
|
112
|
-
|
140
|
+
should "work with ids and modifier hash" do
|
141
|
+
@page_class.push(@page.id, @page2.id, :tags => 'foo')
|
113
142
|
|
114
|
-
|
115
|
-
|
143
|
+
@page.reload
|
144
|
+
@page.tags.should == %w(foo)
|
116
145
|
|
117
|
-
|
118
|
-
|
146
|
+
@page2.reload
|
147
|
+
@page.tags.should == %w(foo)
|
148
|
+
end
|
119
149
|
end
|
120
150
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
151
|
+
context "push_all" do
|
152
|
+
setup do
|
153
|
+
@page = @page_class.create(:title => 'Home')
|
154
|
+
@page2 = @page_class.create(:title => 'Home')
|
155
|
+
@tags = %w(foo bar)
|
156
|
+
end
|
126
157
|
|
127
|
-
|
128
|
-
|
158
|
+
should "work with criteria and modifier hashes" do
|
159
|
+
@page_class.push_all({:title => 'Home'}, :tags => @tags)
|
129
160
|
|
130
|
-
|
131
|
-
|
132
|
-
end
|
161
|
+
@page.reload
|
162
|
+
@page.tags.should == @tags
|
133
163
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
tags = %w(foo bar)
|
164
|
+
@page2.reload
|
165
|
+
@page.tags.should == @tags
|
166
|
+
end
|
138
167
|
|
139
|
-
|
168
|
+
should "work with ids and modifier hash" do
|
169
|
+
@page_class.push_all(@page.id, @page2.id, :tags => @tags)
|
140
170
|
|
141
|
-
|
142
|
-
|
171
|
+
@page.reload
|
172
|
+
@page.tags.should == @tags
|
143
173
|
|
144
|
-
|
145
|
-
|
174
|
+
@page2.reload
|
175
|
+
@page.tags.should == @tags
|
176
|
+
end
|
146
177
|
end
|
147
178
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
179
|
+
context "pull" do
|
180
|
+
setup do
|
181
|
+
@page = @page_class.create(:title => 'Home', :tags => %w(foo bar))
|
182
|
+
@page2 = @page_class.create(:title => 'Home', :tags => %w(foo bar))
|
183
|
+
end
|
152
184
|
|
153
|
-
|
185
|
+
should "work with criteria and modifier hashes" do
|
186
|
+
@page_class.pull({:title => 'Home'}, :tags => 'foo')
|
154
187
|
|
155
|
-
|
156
|
-
|
188
|
+
@page.reload
|
189
|
+
@page.tags.should == %w(bar)
|
157
190
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
should "be able to pull with criteria and modifier hashes" do
|
163
|
-
page = @page_class.create(:title => 'Home', :tags => %w(foo bar))
|
164
|
-
page2 = @page_class.create(:title => 'Home', :tags => %w(foo bar))
|
191
|
+
@page2.reload
|
192
|
+
@page.tags.should == %w(bar)
|
193
|
+
end
|
165
194
|
|
166
|
-
|
195
|
+
should "be able to pull with ids and modifier hash" do
|
196
|
+
@page_class.pull(@page.id, @page2.id, :tags => 'foo')
|
167
197
|
|
168
|
-
|
169
|
-
|
198
|
+
@page.reload
|
199
|
+
@page.tags.should == %w(bar)
|
170
200
|
|
171
|
-
|
172
|
-
|
201
|
+
@page2.reload
|
202
|
+
@page.tags.should == %w(bar)
|
203
|
+
end
|
173
204
|
end
|
174
205
|
|
175
|
-
|
176
|
-
|
177
|
-
|
206
|
+
context "pull_all" do
|
207
|
+
setup do
|
208
|
+
@page = @page_class.create(:title => 'Home', :tags => %w(foo bar baz))
|
209
|
+
@page2 = @page_class.create(:title => 'Home', :tags => %w(foo bar baz))
|
210
|
+
end
|
178
211
|
|
179
|
-
|
212
|
+
should "work with criteria and modifier hashes" do
|
213
|
+
@page_class.pull_all({:title => 'Home'}, :tags => %w(foo bar))
|
180
214
|
|
181
|
-
|
182
|
-
|
215
|
+
@page.reload
|
216
|
+
@page.tags.should == %w(baz)
|
183
217
|
|
184
|
-
|
185
|
-
|
186
|
-
|
218
|
+
@page2.reload
|
219
|
+
@page.tags.should == %w(baz)
|
220
|
+
end
|
187
221
|
|
188
|
-
|
189
|
-
|
190
|
-
page2 = @page_class.create(:title => 'Home', :tags => %w(foo bar baz))
|
222
|
+
should "work with ids and modifier hash" do
|
223
|
+
@page_class.pull_all(@page.id, @page2.id, :tags => %w(foo bar))
|
191
224
|
|
192
|
-
|
225
|
+
@page.reload
|
226
|
+
@page.tags.should == %w(baz)
|
193
227
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
page2.reload
|
198
|
-
page.tags.should == %w(baz)
|
228
|
+
@page2.reload
|
229
|
+
@page.tags.should == %w(baz)
|
230
|
+
end
|
199
231
|
end
|
200
232
|
|
201
|
-
|
202
|
-
|
203
|
-
|
233
|
+
context "add_to_set" do
|
234
|
+
setup do
|
235
|
+
@page = @page_class.create(:title => 'Home', :tags => 'foo')
|
236
|
+
@page2 = @page_class.create(:title => 'Home')
|
237
|
+
end
|
204
238
|
|
205
|
-
|
239
|
+
should "be able to add to set with criteria and modifier hash" do
|
240
|
+
@page_class.add_to_set({:title => 'Home'}, :tags => 'foo')
|
206
241
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
page2.reload
|
211
|
-
page.tags.should == %w(baz)
|
212
|
-
end
|
242
|
+
@page.reload
|
243
|
+
@page.tags.should == %w(foo)
|
213
244
|
|
214
|
-
|
215
|
-
|
216
|
-
|
245
|
+
@page2.reload
|
246
|
+
@page.tags.should == %w(foo)
|
247
|
+
end
|
217
248
|
|
218
|
-
|
249
|
+
should "be able to add to set with ids and modifier hash" do
|
250
|
+
@page_class.add_to_set(@page.id, @page2.id, :tags => 'foo')
|
219
251
|
|
220
|
-
|
221
|
-
|
252
|
+
@page.reload
|
253
|
+
@page.tags.should == %w(foo)
|
222
254
|
|
223
|
-
|
224
|
-
|
255
|
+
@page2.reload
|
256
|
+
@page.tags.should == %w(foo)
|
257
|
+
end
|
225
258
|
end
|
226
259
|
|
227
|
-
|
228
|
-
|
229
|
-
|
260
|
+
context "push_uniq" do
|
261
|
+
setup do
|
262
|
+
@page = @page_class.create(:title => 'Home', :tags => 'foo')
|
263
|
+
@page2 = @page_class.create(:title => 'Home')
|
264
|
+
end
|
230
265
|
|
231
|
-
|
266
|
+
should "be able to push uniq with criteria and modifier hash" do
|
267
|
+
@page_class.push_uniq({:title => 'Home'}, :tags => 'foo')
|
232
268
|
|
233
|
-
|
234
|
-
|
269
|
+
@page.reload
|
270
|
+
@page.tags.should == %w(foo)
|
235
271
|
|
236
|
-
|
237
|
-
|
238
|
-
|
272
|
+
@page2.reload
|
273
|
+
@page.tags.should == %w(foo)
|
274
|
+
end
|
239
275
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
276
|
+
should "be able to push uniq with ids and modifier hash" do
|
277
|
+
@page_class.push_uniq(@page.id, @page2.id, :tags => 'foo')
|
278
|
+
|
279
|
+
@page.reload
|
280
|
+
@page.tags.should == %w(foo)
|
281
|
+
|
282
|
+
@page2.reload
|
283
|
+
@page.tags.should == %w(foo)
|
284
|
+
end
|
245
285
|
end
|
246
286
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
287
|
+
context "pop" do
|
288
|
+
setup do
|
289
|
+
@page = @page_class.create(:title => 'Home', :tags => %w(foo bar))
|
290
|
+
end
|
291
|
+
|
292
|
+
should "be able to remove the last element the array" do
|
293
|
+
@page_class.pop(@page.id, :tags => 1)
|
294
|
+
@page.reload
|
295
|
+
@page.tags.should == %w(foo)
|
296
|
+
end
|
297
|
+
|
298
|
+
should "be able to remove the first element of the array" do
|
299
|
+
@page_class.pop(@page.id, :tags => -1)
|
300
|
+
@page.reload
|
301
|
+
@page.tags.should == %w(bar)
|
302
|
+
end
|
252
303
|
end
|
253
304
|
end
|
254
305
|
|
255
|
-
context "
|
306
|
+
context "InstanceMethods" do
|
307
|
+
should "be able to unset with keys" do
|
308
|
+
page = @page_class.create(:title => 'Foo', :tags => %w(foo))
|
309
|
+
page.unset(:title, :tags)
|
310
|
+
assert_keys_removed page, :title, :tags
|
311
|
+
end
|
312
|
+
|
256
313
|
should "be able to increment with modifier hashes" do
|
257
314
|
page = @page_class.create
|
258
|
-
|
259
|
-
page.increment({:day_count => 1, :week_count => 2, :month_count => 3})
|
315
|
+
page.increment(:day_count => 1, :week_count => 2, :month_count => 3)
|
260
316
|
|
261
317
|
assert_page_counts page, 1, 2, 3
|
262
318
|
end
|
263
319
|
|
264
320
|
should "be able to decrement with modifier hashes" do
|
265
321
|
page = @page_class.create(:day_count => 1, :week_count => 2, :month_count => 3)
|
266
|
-
|
267
|
-
page.decrement({:day_count => 1, :week_count => 2, :month_count => 3})
|
322
|
+
page.decrement(:day_count => 1, :week_count => 2, :month_count => 3)
|
268
323
|
|
269
324
|
assert_page_counts page, 0, 0, 0
|
270
325
|
end
|
271
326
|
|
272
327
|
should "always decrement when decrement is called whether number is positive or negative" do
|
273
328
|
page = @page_class.create(:day_count => 1, :week_count => 2, :month_count => 3)
|
274
|
-
|
275
|
-
page.decrement({:day_count => -1, :week_count => 2, :month_count => -3})
|
329
|
+
page.decrement(:day_count => -1, :week_count => 2, :month_count => -3)
|
276
330
|
|
277
331
|
assert_page_counts page, 0, 0, 0
|
278
332
|
end
|
279
333
|
|
280
334
|
should "be able to set with modifier hashes" do
|
281
335
|
page = @page_class.create(:title => 'Home')
|
282
|
-
|
283
336
|
page.set(:title => 'Home Revised')
|
284
337
|
|
285
338
|
page.reload
|
@@ -288,7 +341,6 @@ class ModifierTest < Test::Unit::TestCase
|
|
288
341
|
|
289
342
|
should "be able to push with modifier hashes" do
|
290
343
|
page = @page_class.create
|
291
|
-
|
292
344
|
page.push(:tags => 'foo')
|
293
345
|
|
294
346
|
page.reload
|
@@ -296,14 +348,27 @@ class ModifierTest < Test::Unit::TestCase
|
|
296
348
|
end
|
297
349
|
|
298
350
|
should "be able to pull with criteria and modifier hashes" do
|
299
|
-
page
|
300
|
-
|
351
|
+
page = @page_class.create(:tags => %w(foo bar))
|
301
352
|
page.pull(:tags => 'foo')
|
302
353
|
|
303
354
|
page.reload
|
304
355
|
page.tags.should == %w(bar)
|
305
356
|
end
|
306
357
|
|
358
|
+
should "be able to add_to_set with criteria and modifier hash" do
|
359
|
+
page = @page_class.create(:tags => 'foo')
|
360
|
+
page2 = @page_class.create
|
361
|
+
|
362
|
+
page.add_to_set(:tags => 'foo')
|
363
|
+
page.add_to_set(:tags => 'foo')
|
364
|
+
|
365
|
+
page.reload
|
366
|
+
page.tags.should == %w(foo)
|
367
|
+
|
368
|
+
page2.reload
|
369
|
+
page.tags.should == %w(foo)
|
370
|
+
end
|
371
|
+
|
307
372
|
should "be able to push uniq with criteria and modifier hash" do
|
308
373
|
page = @page_class.create(:tags => 'foo')
|
309
374
|
page2 = @page_class.create
|
@@ -320,8 +385,7 @@ class ModifierTest < Test::Unit::TestCase
|
|
320
385
|
|
321
386
|
should "be able to pop with modifier hashes" do
|
322
387
|
page = @page_class.create(:tags => %w(foo bar))
|
323
|
-
|
324
|
-
page.pop({:tags => 1})
|
388
|
+
page.pop(:tags => 1)
|
325
389
|
|
326
390
|
page.reload
|
327
391
|
page.tags.should == %w(foo)
|