mongo_mapper 0.14.0.rc1 → 0.15.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +5 -13
  2. data/LICENSE +1 -1
  3. data/{README.rdoc → README.md} +26 -21
  4. data/examples/keys.rb +1 -1
  5. data/examples/modifiers/set.rb +1 -1
  6. data/examples/querying.rb +1 -1
  7. data/examples/safe.rb +2 -2
  8. data/examples/scopes.rb +1 -1
  9. data/lib/mongo_mapper.rb +3 -0
  10. data/lib/mongo_mapper/connection.rb +16 -38
  11. data/lib/mongo_mapper/extensions/object_id.rb +5 -1
  12. data/lib/mongo_mapper/plugins/accessible.rb +1 -1
  13. data/lib/mongo_mapper/plugins/associations/base.rb +10 -2
  14. data/lib/mongo_mapper/plugins/associations/belongs_to_association.rb +1 -1
  15. data/lib/mongo_mapper/plugins/associations/belongs_to_proxy.rb +6 -0
  16. data/lib/mongo_mapper/plugins/associations/in_array_proxy.rb +36 -6
  17. data/lib/mongo_mapper/plugins/associations/in_foreign_array_proxy.rb +136 -0
  18. data/lib/mongo_mapper/plugins/associations/many_association.rb +4 -2
  19. data/lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb +3 -1
  20. data/lib/mongo_mapper/plugins/associations/proxy.rb +11 -3
  21. data/lib/mongo_mapper/plugins/associations/single_association.rb +5 -4
  22. data/lib/mongo_mapper/plugins/dirty.rb +29 -37
  23. data/lib/mongo_mapper/plugins/document.rb +1 -1
  24. data/lib/mongo_mapper/plugins/dynamic_querying/dynamic_finder.rb +1 -1
  25. data/lib/mongo_mapper/plugins/embedded_callbacks.rb +1 -0
  26. data/lib/mongo_mapper/plugins/embedded_document.rb +2 -2
  27. data/lib/mongo_mapper/plugins/identity_map.rb +3 -1
  28. data/lib/mongo_mapper/plugins/indexes.rb +13 -6
  29. data/lib/mongo_mapper/plugins/keys.rb +12 -7
  30. data/lib/mongo_mapper/plugins/keys/key.rb +13 -8
  31. data/lib/mongo_mapper/plugins/modifiers.rb +39 -14
  32. data/lib/mongo_mapper/plugins/persistence.rb +6 -2
  33. data/lib/mongo_mapper/plugins/querying.rb +9 -3
  34. data/lib/mongo_mapper/plugins/querying/decorated_plucky_query.rb +6 -6
  35. data/lib/mongo_mapper/plugins/safe.rb +10 -4
  36. data/lib/mongo_mapper/plugins/scopes.rb +19 -3
  37. data/lib/mongo_mapper/plugins/stats.rb +1 -3
  38. data/lib/mongo_mapper/plugins/strong_parameters.rb +26 -0
  39. data/lib/mongo_mapper/railtie.rb +1 -0
  40. data/lib/mongo_mapper/utils.rb +2 -2
  41. data/lib/mongo_mapper/version.rb +1 -1
  42. data/spec/examples.txt +1729 -0
  43. data/spec/functional/accessible_spec.rb +7 -1
  44. data/spec/functional/associations/belongs_to_polymorphic_proxy_spec.rb +2 -2
  45. data/spec/functional/associations/belongs_to_proxy_spec.rb +55 -5
  46. data/spec/functional/associations/in_array_proxy_spec.rb +149 -14
  47. data/spec/functional/associations/in_foreign_array_proxy_spec.rb +321 -0
  48. data/spec/functional/associations/many_documents_as_proxy_spec.rb +6 -6
  49. data/spec/functional/associations/many_documents_proxy_spec.rb +22 -22
  50. data/spec/functional/associations/many_embedded_polymorphic_proxy_spec.rb +2 -2
  51. data/spec/functional/associations/many_polymorphic_proxy_spec.rb +4 -4
  52. data/spec/functional/associations/one_as_proxy_spec.rb +8 -8
  53. data/spec/functional/associations/one_embedded_proxy_spec.rb +28 -0
  54. data/spec/functional/associations/one_proxy_spec.rb +19 -9
  55. data/spec/functional/associations_spec.rb +3 -3
  56. data/spec/functional/binary_spec.rb +2 -2
  57. data/spec/functional/caching_spec.rb +15 -22
  58. data/spec/functional/callbacks_spec.rb +2 -2
  59. data/spec/functional/counter_cache_spec.rb +10 -10
  60. data/spec/functional/dirty_spec.rb +48 -10
  61. data/spec/functional/dirty_with_callbacks_spec.rb +59 -0
  62. data/spec/functional/document_spec.rb +5 -8
  63. data/spec/functional/dumpable_spec.rb +1 -1
  64. data/spec/functional/embedded_document_spec.rb +5 -5
  65. data/spec/functional/identity_map_spec.rb +8 -8
  66. data/spec/functional/indexes_spec.rb +19 -18
  67. data/spec/functional/keys_spec.rb +51 -33
  68. data/spec/functional/logger_spec.rb +2 -2
  69. data/spec/functional/modifiers_spec.rb +81 -19
  70. data/spec/functional/partial_updates_spec.rb +8 -8
  71. data/spec/functional/protected_spec.rb +1 -1
  72. data/spec/functional/querying_spec.rb +70 -22
  73. data/spec/functional/safe_spec.rb +23 -27
  74. data/spec/functional/sci_spec.rb +7 -7
  75. data/spec/functional/scopes_spec.rb +89 -1
  76. data/spec/functional/static_keys_spec.rb +2 -2
  77. data/spec/functional/stats_spec.rb +28 -12
  78. data/spec/functional/strong_parameters_spec.rb +49 -0
  79. data/spec/functional/validations_spec.rb +8 -16
  80. data/spec/quality_spec.rb +1 -1
  81. data/spec/spec_helper.rb +39 -8
  82. data/spec/support/matchers.rb +1 -1
  83. data/spec/unit/associations/proxy_spec.rb +13 -5
  84. data/spec/unit/clone_spec.rb +1 -1
  85. data/spec/unit/document_spec.rb +3 -3
  86. data/spec/unit/embedded_document_spec.rb +4 -5
  87. data/spec/unit/extensions_spec.rb +2 -2
  88. data/spec/unit/identity_map_middleware_spec.rb +65 -96
  89. data/spec/unit/key_spec.rb +16 -17
  90. data/spec/unit/keys_spec.rb +17 -8
  91. data/spec/unit/mongo_mapper_spec.rb +41 -88
  92. data/spec/unit/rails_spec.rb +2 -2
  93. data/spec/unit/validations_spec.rb +18 -18
  94. metadata +53 -31
  95. data/lib/mongo_mapper/extensions/ordered_hash.rb +0 -23
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe "ManyDocumentsAsProxy" do
4
4
  before do
5
- Post.collection.remove
6
- PostComment.collection.remove
5
+ Post.collection.drop
6
+ PostComment.collection.drop
7
7
  end
8
8
 
9
9
  it "should default reader to empty array" do
@@ -155,9 +155,9 @@ describe "ManyDocumentsAsProxy" do
155
155
  end
156
156
 
157
157
  it "should not work for id not in association" do
158
- expect {
158
+ lambda {
159
159
  @post.comments.find!(@comment5._id)
160
- }.to raise_error(MongoMapper::DocumentNotFound)
160
+ }.should raise_error(MongoMapper::DocumentNotFound)
161
161
  end
162
162
  end
163
163
 
@@ -168,9 +168,9 @@ describe "ManyDocumentsAsProxy" do
168
168
  end
169
169
 
170
170
  it "should not work for ids not in association" do
171
- expect {
171
+ lambda {
172
172
  @post.comments.find!(@comment1._id, @comment2._id, @comment4._id)
173
- }.to raise_error(MongoMapper::DocumentNotFound)
173
+ }.should raise_error(MongoMapper::DocumentNotFound)
174
174
  end
175
175
  end
176
176
 
@@ -2,8 +2,8 @@ require 'spec_helper.rb'
2
2
 
3
3
  describe "ManyDocumentsProxy" do
4
4
  before do
5
- Project.collection.remove
6
- Status.collection.remove
5
+ Project.collection.drop
6
+ Status.collection.drop
7
7
 
8
8
  @pet_class = Doc do
9
9
  key :name, String
@@ -171,9 +171,9 @@ describe "ManyDocumentsProxy" do
171
171
  end
172
172
 
173
173
  it "should call destroy the existing documents" do
174
- expect(@broker.properties[0]).to receive(:destroy).once
175
- expect(@broker.properties[1]).to receive(:destroy).once
176
- expect(@broker.properties[2]).to receive(:destroy).once
174
+ @broker.properties[0].should_receive(:destroy).once
175
+ @broker.properties[1].should_receive(:destroy).once
176
+ @broker.properties[2].should_receive(:destroy).once
177
177
  @broker.properties = [@property_class.new]
178
178
  end
179
179
 
@@ -184,9 +184,9 @@ describe "ManyDocumentsProxy" do
184
184
  end
185
185
 
186
186
  it "should skip over documents that are the same" do
187
- expect(@broker.properties[0]).to receive(:destroy).never
188
- expect(@broker.properties[1]).to receive(:destroy).once
189
- expect(@broker.properties[2]).to receive(:destroy).never
187
+ @broker.properties[0].should_receive(:destroy).never
188
+ @broker.properties[1].should_receive(:destroy).once
189
+ @broker.properties[2].should_receive(:destroy).never
190
190
  @broker.properties = [@property3, @property1]
191
191
  end
192
192
  end
@@ -205,9 +205,9 @@ describe "ManyDocumentsProxy" do
205
205
  end
206
206
 
207
207
  it "should call delete the existing documents" do
208
- expect(@broker.properties[0]).to receive(:delete).once
209
- expect(@broker.properties[1]).to receive(:delete).once
210
- expect(@broker.properties[2]).to receive(:delete).once
208
+ @broker.properties[0].should_receive(:delete).once
209
+ @broker.properties[1].should_receive(:delete).once
210
+ @broker.properties[2].should_receive(:delete).once
211
211
  @broker.properties = [@property_class.new]
212
212
  end
213
213
 
@@ -218,9 +218,9 @@ describe "ManyDocumentsProxy" do
218
218
  end
219
219
 
220
220
  it "should skip over documents that are the same" do
221
- expect(@broker.properties[0]).to receive(:delete).never
222
- expect(@broker.properties[1]).to receive(:delete).once
223
- expect(@broker.properties[2]).to receive(:delete).never
221
+ @broker.properties[0].should_receive(:delete).never
222
+ @broker.properties[1].should_receive(:delete).once
223
+ @broker.properties[2].should_receive(:delete).never
224
224
  @broker.properties = [@property3, @property1]
225
225
  end
226
226
  end
@@ -430,9 +430,9 @@ describe "ManyDocumentsProxy" do
430
430
 
431
431
  it "should raise exception if not valid" do
432
432
  project = Project.create
433
- expect {
433
+ lambda {
434
434
  project.statuses.create!(:name => nil)
435
- }.to raise_error(MongoMapper::DocumentNotValid)
435
+ }.should raise_error(MongoMapper::DocumentNotValid)
436
436
  end
437
437
 
438
438
  it "should reset cache" do
@@ -754,9 +754,9 @@ describe "ManyDocumentsProxy" do
754
754
  end
755
755
 
756
756
  it "should not work for ids not in association" do
757
- expect {
757
+ lambda {
758
758
  @project1.statuses.find!(@brand_new.id, @complete.id, @archived.id)
759
- }.to raise_error(MongoMapper::DocumentNotFound)
759
+ }.should raise_error(MongoMapper::DocumentNotFound)
760
760
  end
761
761
  end
762
762
 
@@ -810,13 +810,13 @@ describe "ManyDocumentsProxy" do
810
810
  class ::Property
811
811
  include MongoMapper::Document
812
812
  end
813
- Property.collection.remove
813
+ Property.collection.drop
814
814
 
815
815
  class ::Thing
816
816
  include MongoMapper::Document
817
817
  key :name, String
818
818
  end
819
- Thing.collection.remove
819
+ Thing.collection.drop
820
820
  end
821
821
 
822
822
  after do
@@ -997,7 +997,7 @@ describe "ManyDocumentsProxy" do
997
997
 
998
998
  lambda do
999
999
  @job_title_2.trainings.find_by_slug!('bar')
1000
- end.should raise_error
1000
+ end.should raise_error(RuntimeError)
1001
1001
  end
1002
1002
 
1003
1003
  it "should scope with an extra where clause on the proxy (regression #2)" do
@@ -1018,7 +1018,7 @@ describe "ManyDocumentsProxy" do
1018
1018
 
1019
1019
  lambda do
1020
1020
  @job_title_2.trainings.find_by_slug!('bar')
1021
- end.should raise_error
1021
+ end.should raise_error(RuntimeError)
1022
1022
  end
1023
1023
  end
1024
1024
  end
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe "ManyEmbeddedPolymorphicProxy" do
4
4
  before do
5
- Catalog.collection.remove
6
- TrModels::Fleet.collection.remove
5
+ Catalog.collection.drop
6
+ TrModels::Fleet.collection.drop
7
7
  end
8
8
 
9
9
  it "should default reader to empty array" do
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe "ManyPolymorphicProxy" do
4
4
  before do
5
- Room.collection.remove
6
- Message.collection.remove
5
+ Room.collection.drop
6
+ Message.collection.drop
7
7
  end
8
8
 
9
9
  it "should default reader to empty array" do
@@ -247,9 +247,9 @@ describe "ManyPolymorphicProxy" do
247
247
  end
248
248
 
249
249
  it "should not work for ids not in association" do
250
- expect {
250
+ lambda {
251
251
  @lounge.messages.find!(@lm1._id, @lm2._id, @hm2._id)
252
- }.to raise_error(MongoMapper::DocumentNotFound)
252
+ }.should raise_error(MongoMapper::DocumentNotFound)
253
253
  end
254
254
  end
255
255
 
@@ -132,7 +132,7 @@ describe "OneAsProxy" do
132
132
  end
133
133
 
134
134
  it "should call delete on the existing document" do
135
- expect_any_instance_of(@author_class).to receive(:delete).once
135
+ @author_class.any_instance.should_receive(:delete).once
136
136
  @post.author = @author_class.new
137
137
  end
138
138
 
@@ -142,7 +142,7 @@ describe "OneAsProxy" do
142
142
  end
143
143
 
144
144
  it "should do nothing if it's the same document" do
145
- expect_any_instance_of(@author_class).to receive(:delete).never
145
+ @author_class.any_instance.should_receive(:delete).never
146
146
  @post.author = @author
147
147
  end
148
148
  end
@@ -157,7 +157,7 @@ describe "OneAsProxy" do
157
157
  end
158
158
 
159
159
  it "should call destroy the existing document" do
160
- expect_any_instance_of(@author_class).to receive(:destroy).once
160
+ @author_class.any_instance.should_receive(:destroy).once
161
161
  @post.author = @author_class.new
162
162
  end
163
163
 
@@ -167,7 +167,7 @@ describe "OneAsProxy" do
167
167
  end
168
168
 
169
169
  it "should do nothing if it's the same document" do
170
- expect_any_instance_of(@author_class).to receive(:destroy).never
170
+ @author_class.any_instance.should_receive(:destroy).never
171
171
  @post.author = @author
172
172
  end
173
173
  end
@@ -302,7 +302,7 @@ describe "OneAsProxy" do
302
302
  end
303
303
 
304
304
  it "should should call destroy on the associated documents" do
305
- expect_any_instance_of(@author_class).to receive(:destroy).once
305
+ @author_class.any_instance.should_receive(:destroy).once
306
306
  @post.destroy
307
307
  end
308
308
 
@@ -324,7 +324,7 @@ describe "OneAsProxy" do
324
324
  end
325
325
 
326
326
  it "should should call delete the associated documents" do
327
- expect_any_instance_of(@author_class).to receive(:delete).once
327
+ @author_class.any_instance.should_receive(:delete).once
328
328
  @post.destroy
329
329
  end
330
330
 
@@ -445,7 +445,7 @@ describe "OneAsProxy" do
445
445
  end
446
446
 
447
447
  it "should raise exception if invalid" do
448
- expect { @post.create_author! }.to raise_error(MongoMapper::DocumentNotValid)
448
+ lambda { @post.create_author! }.should raise_error(MongoMapper::DocumentNotValid)
449
449
  end
450
450
 
451
451
  it "should work if valid" do
@@ -486,4 +486,4 @@ describe "OneAsProxy" do
486
486
  article.articleable_id.should == @paper.id
487
487
  end
488
488
  end
489
- end
489
+ end
@@ -97,4 +97,32 @@ describe "OneEmbeddedProxy" do
97
97
  post.author.address.id.should_not be_nil
98
98
  end
99
99
 
100
+ it "should keep the reference to assigned document" do
101
+ @post_class.one(:author, :class => @author_class)
102
+ post = @post_class.new
103
+ new_author = @author_class.new
104
+ post.author = new_author
105
+ new_author.name = 'Frank'
106
+
107
+ post.author.name.should == 'Frank'
108
+ end
109
+
110
+ it "should update references for parent and root" do
111
+ @post_class.key(:author_name, String)
112
+ @post_class.one(:author, :class => @author_class)
113
+ @post_class.before_save do
114
+ self.author_name = author.name
115
+ end
116
+
117
+ author = @author_class.new
118
+ @post_class.create!(author: author)
119
+ author.save!
120
+
121
+ post = @post_class.create!(author: author)
122
+ post.author.name = 'Frank'
123
+ post.author.save!
124
+
125
+ post.author.name.should == 'Frank'
126
+ post.author_name.should == 'Frank'
127
+ end
100
128
  end
@@ -97,7 +97,7 @@ describe "OneProxy" do
97
97
  end
98
98
 
99
99
  it "should call delete on the existing document" do
100
- expect_any_instance_of(@author_class).to receive(:delete).once
100
+ @author_class.any_instance.should_receive(:delete).once
101
101
  @post.author = @author_class.new
102
102
  end
103
103
 
@@ -107,7 +107,7 @@ describe "OneProxy" do
107
107
  end
108
108
 
109
109
  it "should do nothing if it's the same document" do
110
- expect_any_instance_of(@author_class).to receive(:delete).never
110
+ @author_class.any_instance.should_receive(:delete).never
111
111
  @post.author = @author
112
112
  end
113
113
  end
@@ -122,7 +122,7 @@ describe "OneProxy" do
122
122
  end
123
123
 
124
124
  it "should call destroy the existing document" do
125
- expect_any_instance_of(@author_class).to receive(:destroy).once
125
+ @author_class.any_instance.should_receive(:destroy).once
126
126
  @post.author = @author_class.new
127
127
  end
128
128
 
@@ -132,7 +132,7 @@ describe "OneProxy" do
132
132
  end
133
133
 
134
134
  it "should do nothing if it's the same document" do
135
- expect_any_instance_of(@author_class).to receive(:destroy).never
135
+ @author_class.any_instance.should_receive(:destroy).never
136
136
  @post.author = @author
137
137
  end
138
138
  end
@@ -246,7 +246,7 @@ describe "OneProxy" do
246
246
  end
247
247
 
248
248
  it "should should call destroy on the associated documents" do
249
- expect_any_instance_of(@author_class).to receive(:destroy).once
249
+ @author_class.any_instance.should_receive(:destroy).once
250
250
  @post.destroy
251
251
  end
252
252
 
@@ -268,7 +268,7 @@ describe "OneProxy" do
268
268
  end
269
269
 
270
270
  it "should should call delete the associated documents" do
271
- expect_any_instance_of(@author_class).to receive(:delete).once
271
+ @author_class.any_instance.should_receive(:delete).once
272
272
  @post.destroy
273
273
  end
274
274
 
@@ -366,9 +366,9 @@ describe "OneProxy" do
366
366
  end
367
367
 
368
368
  it "should raise exception if invalid" do
369
- expect {
369
+ lambda {
370
370
  post.create_author!
371
- }.to raise_error(MongoMapper::DocumentNotValid)
371
+ }.should raise_error(MongoMapper::DocumentNotValid)
372
372
  end
373
373
 
374
374
  it "should work if valid" do
@@ -403,4 +403,14 @@ describe "OneProxy" do
403
403
  article.paper_id.should == @paper.id
404
404
  end
405
405
  end
406
- end
406
+
407
+ it "should keep the reference to assigned document" do
408
+ @post_class.one(:author, :class => @author_class)
409
+ post = @post_class.new
410
+ new_author = @author_class.new
411
+ post.author = new_author
412
+ new_author.name = 'Frank'
413
+
414
+ post.author.name.should == 'Frank'
415
+ end
416
+ end
@@ -9,7 +9,7 @@ module AssociationsSpec
9
9
 
10
10
  many :posts, :class_name => 'AssociationsSpec::AwesomePost', :foreign_key => :creator_id
11
11
  end
12
- AwesomeUser.collection.remove
12
+ AwesomeUser.collection.drop
13
13
 
14
14
  class AwesomeTag
15
15
  include MongoMapper::EmbeddedDocument
@@ -29,8 +29,8 @@ module AssociationsSpec
29
29
  many :tags, :class_name => 'AssociationsSpec::AwesomeTag', :foreign_key => :post_id
30
30
  end
31
31
 
32
- AwesomeUser.collection.remove
33
- AwesomePost.collection.remove
32
+ AwesomeUser.collection.drop
33
+ AwesomePost.collection.drop
34
34
 
35
35
  user = AwesomeUser.create
36
36
  tag1 = AwesomeTag.new(:name => 'awesome')
@@ -10,7 +10,7 @@ describe "Binary" do
10
10
  doc.save
11
11
 
12
12
  doc = doc.reload
13
- doc.contents.to_s.should == BSON::Binary.new('010101').to_s
13
+ doc.contents.data.should == BSON::Binary.new('010101').data
14
14
  end
15
15
 
16
16
  context "Saving a document with a blank binary value" do
@@ -21,7 +21,7 @@ describe "Binary" do
21
21
  end
22
22
 
23
23
  it "not fail" do
24
- expect { @document.new(:file => nil).save }.to_not raise_error
24
+ lambda { @document.new(:file => nil).save }.should_not raise_error
25
25
  end
26
26
  end
27
27
  end
@@ -6,16 +6,16 @@ describe "Caching" do
6
6
  extend MongoMapper::Plugins
7
7
  plugin MongoMapper::Plugins::Caching
8
8
  end
9
- allow(@klass).to receive(:name).and_return('Post')
10
- allow_any_instance_of(@klass).to receive(:persisted?).and_return(true)
11
- allow_any_instance_of(@klass).to receive(:[]).and_return(nil)
12
- allow_any_instance_of(@klass).to receive(:[]=).and_return(nil)
9
+ @klass.stub(:name).and_return('Post')
10
+ @klass.any_instance.stub(:persisted?).and_return(true)
11
+ @klass.any_instance.stub(:[]).and_return(nil)
12
+ @klass.any_instance.stub(:[]=).and_return(nil)
13
13
  end
14
14
 
15
15
  context "new" do
16
16
  before do
17
17
  @doc = @klass.new
18
- allow(@doc).to receive(:persisted?).and_return(false)
18
+ @doc.stub(:persisted?).and_return(false)
19
19
  end
20
20
 
21
21
  it "should be class/new" do
@@ -23,11 +23,9 @@ describe "Caching" do
23
23
  end
24
24
 
25
25
  it "should work with suffix" do
26
- @doc.cache_key(:foo).
27
- should == 'Post/new/foo'
26
+ @doc.cache_key(:foo).should == 'Post/new/foo'
28
27
 
29
- @doc.cache_key(:foo, :bar).
30
- should == 'Post/new/foo/bar'
28
+ @doc.cache_key(:foo, :bar).should == 'Post/new/foo/bar'
31
29
  end
32
30
  end
33
31
 
@@ -35,14 +33,14 @@ describe "Caching" do
35
33
  before do
36
34
  @object_id = BSON::ObjectId.new
37
35
  @doc = @klass.new
38
- allow(@doc).to receive(:persisted).and_return(true)
39
- allow(@doc).to receive(:id).and_return(@object_id)
36
+ @doc.stub(:persisted?).and_return(true)
37
+ @doc.stub(:id).and_return(@object_id)
40
38
  end
41
39
 
42
40
  context "with updated_at" do
43
41
  before do
44
42
  time = Time.utc(2010, 6, 20, 8, 10, 7)
45
- allow(@doc).to receive(:[]).with(:updated_at).and_return(time)
43
+ @doc.stub(:[]).with(:updated_at).and_return(time)
46
44
  end
47
45
 
48
46
  it "should be class/id-timestamp" do
@@ -50,11 +48,9 @@ describe "Caching" do
50
48
  end
51
49
 
52
50
  it "should work with suffix" do
53
- @doc.cache_key(:foo).
54
- should == "Post/#{@object_id}-20100620081007/foo"
51
+ @doc.cache_key(:foo).should == "Post/#{@object_id}-20100620081007/foo"
55
52
 
56
- @doc.cache_key(:foo, :bar).
57
- should == "Post/#{@object_id}-20100620081007/foo/bar"
53
+ @doc.cache_key(:foo, :bar).should == "Post/#{@object_id}-20100620081007/foo/bar"
58
54
  end
59
55
  end
60
56
 
@@ -64,12 +60,9 @@ describe "Caching" do
64
60
  end
65
61
 
66
62
  it "should work with suffix" do
67
- @doc.cache_key(:foo).
68
- should == "Post/#{@object_id}/foo"
69
-
70
- @doc.cache_key(:foo, :bar, :baz).
71
- should == "Post/#{@object_id}/foo/bar/baz"
63
+ @doc.cache_key(:foo).should == "Post/#{@object_id}/foo"
64
+ @doc.cache_key(:foo, :bar, :baz).should == "Post/#{@object_id}/foo/bar/baz"
72
65
  end
73
66
  end
74
67
  end
75
- end
68
+ end