mongo_mapper 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. data/Rakefile +3 -2
  2. data/lib/mongo_mapper.rb +2 -3
  3. data/lib/mongo_mapper/plugins/associations.rb +10 -1
  4. data/lib/mongo_mapper/plugins/associations/base.rb +2 -2
  5. data/lib/mongo_mapper/plugins/associations/many_documents_proxy.rb +12 -3
  6. data/lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb +41 -0
  7. data/lib/mongo_mapper/plugins/associations/one_proxy.rb +1 -0
  8. data/lib/mongo_mapper/plugins/associations/proxy.rb +8 -2
  9. data/lib/mongo_mapper/plugins/callbacks.rb +7 -3
  10. data/lib/mongo_mapper/plugins/descendants.rb +2 -2
  11. data/lib/mongo_mapper/plugins/keys.rb +14 -7
  12. data/lib/mongo_mapper/plugins/modifiers.rb +30 -14
  13. data/lib/mongo_mapper/plugins/protected.rb +1 -1
  14. data/lib/mongo_mapper/plugins/serialization.rb +1 -1
  15. data/lib/mongo_mapper/query.rb +27 -19
  16. data/lib/mongo_mapper/support.rb +10 -6
  17. data/lib/mongo_mapper/version.rb +1 -1
  18. data/mongo_mapper.gemspec +14 -8
  19. data/test/functional/associations/test_belongs_to_polymorphic_proxy.rb +1 -1
  20. data/test/functional/associations/test_belongs_to_proxy.rb +1 -1
  21. data/test/functional/associations/test_many_documents_proxy.rb +100 -17
  22. data/test/functional/associations/test_one_embedded_proxy.rb +68 -0
  23. data/test/functional/associations/test_one_proxy.rb +48 -13
  24. data/test/functional/test_binary.rb +1 -1
  25. data/test/functional/test_document.rb +7 -7
  26. data/test/functional/test_embedded_document.rb +8 -0
  27. data/test/functional/test_identity_map.rb +2 -2
  28. data/test/functional/test_modifiers.rb +249 -185
  29. data/test/functional/test_protected.rb +4 -0
  30. data/test/functional/test_string_id_compatibility.rb +1 -1
  31. data/test/support/custom_matchers.rb +0 -18
  32. data/test/test_helper.rb +6 -4
  33. data/test/unit/associations/test_base.rb +7 -2
  34. data/test/unit/test_document.rb +5 -5
  35. data/test/unit/test_embedded_document.rb +7 -7
  36. data/test/unit/test_query.rb +17 -7
  37. data/test/unit/test_support.rb +26 -14
  38. 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 = Mongo::ObjectID.new
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' => Mongo::ObjectID.new, 'title' => 'Awesome!'})
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, String
7
- key :day_count, Integer, :default => 0
8
- key :week_count, Integer, :default => 0
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, Array
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
- context "using class methods" do
22
- should "be able to increment with criteria and modifier hashes" do
23
- page = @page_class.create(:title => 'Home')
24
- page2 = @page_class.create(:title => 'Home')
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
- should "be able to increment with ids and modifier hash" do
35
- page = @page_class.create(:title => 'Home')
36
- page2 = @page_class.create(:title => 'Home')
37
-
38
- @page_class.increment(page.id, page2.id, {
39
- :day_count => 1, :week_count => 2, :month_count => 3
40
- })
41
-
42
- assert_page_counts page, 1, 2, 3
43
- assert_page_counts page2, 1, 2, 3
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
- should "be able to decrement with criteria and modifier hashes" do
47
- page = @page_class.create(:title => 'Home', :day_count => 1, :week_count => 2, :month_count => 3)
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
- should "be able to decrement with ids and modifier hash" do
59
- page = @page_class.create(:title => 'Home', :day_count => 1, :week_count => 2, :month_count => 3)
60
- page2 = @page_class.create(:title => 'Home', :day_count => 1, :week_count => 2, :month_count => 3)
57
+ assert_page_counts @page, 1, 2, 3
58
+ assert_page_counts @page2, 1, 2, 3
59
+ end
61
60
 
62
- @page_class.decrement(page.id, page2.id, {
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
- assert_page_counts page, 0, 0, 0
67
- assert_page_counts page2, 0, 0, 0
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
- should "always decrement when decrement is called whether number is positive or negative" 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)
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
- @page_class.decrement(page.id, page2.id, {
75
- :day_count => -1, :week_count => 2, :month_count => -3
76
- })
103
+ should "work with criteria and modifier hashes" do
104
+ @page_class.set({:title => 'Home'}, :title => 'Home Revised')
77
105
 
78
- assert_page_counts page, 0, 0, 0
79
- assert_page_counts page2, 0, 0, 0
80
- end
106
+ @page.reload
107
+ @page.title.should == 'Home Revised'
81
108
 
82
- should "be able to set with criteria and modifier hashes" do
83
- page = @page_class.create(:title => 'Home')
84
- page2 = @page_class.create(:title => 'Home')
109
+ @page2.reload
110
+ @page2.title.should == 'Home Revised'
111
+ end
85
112
 
86
- @page_class.set({:title => 'Home'}, :title => 'Home Revised')
113
+ should "work with ids and modifier hash" do
114
+ @page_class.set(@page.id, @page2.id, :title => 'Home Revised')
87
115
 
88
- page.reload
89
- page.title.should == 'Home Revised'
116
+ @page.reload
117
+ @page.title.should == 'Home Revised'
90
118
 
91
- page2.reload
92
- page2.title.should == 'Home Revised'
119
+ @page2.reload
120
+ @page2.title.should == 'Home Revised'
121
+ end
93
122
  end
94
123
 
95
- should "be able to set with ids and modifier hash" do
96
- page = @page_class.create(:title => 'Home')
97
- page2 = @page_class.create(:title => 'Home')
98
-
99
- @page_class.set(page.id, page2.id, :title => 'Home Revised')
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
- page.reload
102
- page.title.should == 'Home Revised'
130
+ should "work with criteria and modifier hashes" do
131
+ @page_class.push({:title => 'Home'}, :tags => 'foo')
103
132
 
104
- page2.reload
105
- page2.title.should == 'Home Revised'
106
- end
133
+ @page.reload
134
+ @page.tags.should == %w(foo)
107
135
 
108
- should "be able to push with criteria and modifier hashes" do
109
- page = @page_class.create(:title => 'Home')
110
- page2 = @page_class.create(:title => 'Home')
136
+ @page2.reload
137
+ @page.tags.should == %w(foo)
138
+ end
111
139
 
112
- @page_class.push({:title => 'Home'}, :tags => 'foo')
140
+ should "work with ids and modifier hash" do
141
+ @page_class.push(@page.id, @page2.id, :tags => 'foo')
113
142
 
114
- page.reload
115
- page.tags.should == %w(foo)
143
+ @page.reload
144
+ @page.tags.should == %w(foo)
116
145
 
117
- page2.reload
118
- page.tags.should == %w(foo)
146
+ @page2.reload
147
+ @page.tags.should == %w(foo)
148
+ end
119
149
  end
120
150
 
121
- should "be able to push with ids and modifier hash" do
122
- page = @page_class.create(:title => 'Home')
123
- page2 = @page_class.create(:title => 'Home')
124
-
125
- @page_class.push(page.id, page2.id, :tags => 'foo')
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
- page.reload
128
- page.tags.should == %w(foo)
158
+ should "work with criteria and modifier hashes" do
159
+ @page_class.push_all({:title => 'Home'}, :tags => @tags)
129
160
 
130
- page2.reload
131
- page.tags.should == %w(foo)
132
- end
161
+ @page.reload
162
+ @page.tags.should == @tags
133
163
 
134
- should "be able to push all with criteria and modifier hashes" do
135
- page = @page_class.create(:title => 'Home')
136
- page2 = @page_class.create(:title => 'Home')
137
- tags = %w(foo bar)
164
+ @page2.reload
165
+ @page.tags.should == @tags
166
+ end
138
167
 
139
- @page_class.push_all({:title => 'Home'}, :tags => tags)
168
+ should "work with ids and modifier hash" do
169
+ @page_class.push_all(@page.id, @page2.id, :tags => @tags)
140
170
 
141
- page.reload
142
- page.tags.should == tags
171
+ @page.reload
172
+ @page.tags.should == @tags
143
173
 
144
- page2.reload
145
- page.tags.should == tags
174
+ @page2.reload
175
+ @page.tags.should == @tags
176
+ end
146
177
  end
147
178
 
148
- should "be able to push all with ids and modifier hash" do
149
- page = @page_class.create(:title => 'Home')
150
- page2 = @page_class.create(:title => 'Home')
151
- tags = %w(foo bar)
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
- @page_class.push_all(page.id, page2.id, :tags => tags)
185
+ should "work with criteria and modifier hashes" do
186
+ @page_class.pull({:title => 'Home'}, :tags => 'foo')
154
187
 
155
- page.reload
156
- page.tags.should == tags
188
+ @page.reload
189
+ @page.tags.should == %w(bar)
157
190
 
158
- page2.reload
159
- page.tags.should == tags
160
- end
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
- @page_class.pull({:title => 'Home'}, :tags => 'foo')
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
- page.reload
169
- page.tags.should == %w(bar)
198
+ @page.reload
199
+ @page.tags.should == %w(bar)
170
200
 
171
- page2.reload
172
- page.tags.should == %w(bar)
201
+ @page2.reload
202
+ @page.tags.should == %w(bar)
203
+ end
173
204
  end
174
205
 
175
- should "be able to pull with ids and modifier hash" do
176
- page = @page_class.create(:title => 'Home', :tags => %w(foo bar))
177
- page2 = @page_class.create(:title => 'Home', :tags => %w(foo bar))
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
- @page_class.pull(page.id, page2.id, :tags => 'foo')
212
+ should "work with criteria and modifier hashes" do
213
+ @page_class.pull_all({:title => 'Home'}, :tags => %w(foo bar))
180
214
 
181
- page.reload
182
- page.tags.should == %w(bar)
215
+ @page.reload
216
+ @page.tags.should == %w(baz)
183
217
 
184
- page2.reload
185
- page.tags.should == %w(bar)
186
- end
218
+ @page2.reload
219
+ @page.tags.should == %w(baz)
220
+ end
187
221
 
188
- should "be able to pull all with criteria and modifier hashes" do
189
- page = @page_class.create(:title => 'Home', :tags => %w(foo bar baz))
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
- @page_class.pull_all({:title => 'Home'}, :tags => %w(foo bar))
225
+ @page.reload
226
+ @page.tags.should == %w(baz)
193
227
 
194
- page.reload
195
- page.tags.should == %w(baz)
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
- should "be able to pull all with ids and modifier hash" do
202
- page = @page_class.create(:title => 'Home', :tags => %w(foo bar baz))
203
- page2 = @page_class.create(:title => 'Home', :tags => %w(foo bar baz))
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
- @page_class.pull_all(page.id, page2.id, :tags => %w(foo bar))
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
- page.reload
208
- page.tags.should == %w(baz)
209
-
210
- page2.reload
211
- page.tags.should == %w(baz)
212
- end
242
+ @page.reload
243
+ @page.tags.should == %w(foo)
213
244
 
214
- should "be able to push uniq with criteria and modifier hash" do
215
- page = @page_class.create(:title => 'Home', :tags => 'foo')
216
- page2 = @page_class.create(:title => 'Home')
245
+ @page2.reload
246
+ @page.tags.should == %w(foo)
247
+ end
217
248
 
218
- @page_class.push_uniq({:title => 'Home'}, :tags => 'foo')
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
- page.reload
221
- page.tags.should == %w(foo)
252
+ @page.reload
253
+ @page.tags.should == %w(foo)
222
254
 
223
- page2.reload
224
- page.tags.should == %w(foo)
255
+ @page2.reload
256
+ @page.tags.should == %w(foo)
257
+ end
225
258
  end
226
259
 
227
- should "be able to push uniq with ids and modifier hash" do
228
- page = @page_class.create(:title => 'Home', :tags => 'foo')
229
- page2 = @page_class.create(:title => 'Home')
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
- @page_class.push_uniq(page.id, page2.id, :tags => 'foo')
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
- page.reload
234
- page.tags.should == %w(foo)
269
+ @page.reload
270
+ @page.tags.should == %w(foo)
235
271
 
236
- page2.reload
237
- page.tags.should == %w(foo)
238
- end
272
+ @page2.reload
273
+ @page.tags.should == %w(foo)
274
+ end
239
275
 
240
- should "be able to remove the last element the array" do
241
- page = @page_class.create(:title => 'Home', :tags => %w(foo bar))
242
- @page_class.pop(page.id, :tags => 1)
243
- page.reload
244
- page.tags.should == %w(foo)
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
- should "be able to remove the first element of the array" do
248
- page = @page_class.create(:title => 'Home', :tags => %w(foo bar))
249
- @page_class.pop(page.id, :tags => -1)
250
- page.reload
251
- page.tags.should == %w(bar)
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 "using instance methods" do
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 = @page_class.create(:tags => %w(foo bar))
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)