File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -257,10 +257,26 @@ RSpec.describe Article do
257
257
end
258
258
259
259
# when the touch option is provided, then we can also verify that it is set.
260
+
261
+ # by default, with_touch matches true when no parameters are provided.
262
+ describe Article do
263
+ it { is_expected.to belong_to(:author ).of_type(User ).as_inverse_of(:articles ).with_index.with_touch }
264
+ end
265
+
266
+ # parameters are supported for explicit matching.
267
+ describe Comment do
268
+ it { is_expected.to be_embedded_in(:article ).as_inverse_of(:comments ).with_polymorphism.with_touch(true ) }
269
+ end
270
+
260
271
describe Permalink do
261
272
it { is_expected.to be_embedded_in(:linkable ).as_inverse_of(:link ).with_touch(false ) }
262
273
end
263
274
275
+ # touch can also take a symbol represneting a field on the parent to touch.
276
+ describe Record do
277
+ it { is_expected.to belong_to(:user ).as_inverse_of(:record ).with_touch(:record_updated_at ) }
278
+ end
279
+
264
280
RSpec .describe Comment do
265
281
it { is_expected.to be_embedded_in(:article ).as_inverse_of(:comments ) }
266
282
it { is_expected.to belong_to(:user ).as_inverse_of(:comments ) }
You can’t perform that action at this time.
0 commit comments