goldiloader 0.0.9 → 2.1.2

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.
@@ -1,737 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Goldiloader do
6
- let!(:author1) do
7
- User.create!(name: 'author1') { |u| u.address = Address.new(city: 'author1-city') }
8
- end
9
-
10
- let!(:author2) do
11
- User.create!(name: 'author2') { |u| u.address = Address.new(city: 'author2-city') }
12
- end
13
-
14
- let!(:author3) do
15
- User.create!(name: 'author3') { |u| u.address = Address.new(city: 'author3-city') }
16
- end
17
-
18
- let!(:group1) { Group.create!(name: 'group1') }
19
-
20
- let!(:parent_tag1) { Tag.create!(name: 'parent1') { |t| t.owner = group1 } }
21
- let!(:child_tag1) { parent_tag1.children.create!(name: 'parent1-child1') { |t| t.owner = author1 } }
22
- let!(:child_tag2) { parent_tag1.children.create!(name: 'parent1-child2') { |t| t.owner = group1 } }
23
- let!(:parent_tag2) { Tag.create!(name: 'parent2') { |t| t.owner = group1 } }
24
- let!(:child_tag3) { parent_tag2.children.create!(name: 'parent2-child1') { |t| t.owner = author2 } }
25
-
26
- let!(:blog1) do
27
- blog1 = Blog.create!(name: 'blog1')
28
-
29
- blog1.posts.create!(title: 'blog1-post1') do |post|
30
- post.author = author1
31
- post.tags << child_tag1 << child_tag2
32
- end
33
-
34
- blog1.posts.create!(title: 'blog1-post2') do |post|
35
- post.author = author2
36
- post.tags << child_tag1
37
- end
38
-
39
- blog1
40
- end
41
-
42
- let!(:blog2) do
43
- blog2 = Blog.create!(name: 'blog2')
44
-
45
- blog2.posts.create!(title: 'blog2-post1') do |post|
46
- post.author = author3
47
- post.tags << child_tag1
48
- end
49
-
50
- blog2.posts.create!(title: 'blog2-post2') do |post|
51
- post.author = author1
52
- post.tags << child_tag3
53
- end
54
-
55
- blog2
56
- end
57
-
58
- before do
59
- [Address, Blog, Post, Tag, User, Group].each do |klass|
60
- allow(klass).to receive(:find_by_sql).and_call_original
61
- end
62
-
63
- ActiveRecord::Base.logger.info('Test setup complete')
64
- end
65
-
66
- it "auto eager loads has_many associations" do
67
- blogs = Blog.order(:name).to_a
68
-
69
- # Sanity check that associations aren't loaded yet
70
- blogs.each do |blog|
71
- expect(blog.association(:posts)).to_not be_loaded
72
- end
73
-
74
- # Force the first blogs first post to load
75
- blogs.first.posts.to_a
76
-
77
- blogs.each do |blog|
78
- expect(blog.association(:posts)).to be_loaded
79
- end
80
-
81
- expect(blogs.first.posts.map(&:title)).to match_array(['blog1-post1', 'blog1-post2'])
82
- expect(blogs.second.posts.map(&:title)).to match_array(['blog2-post1', 'blog2-post2'])
83
-
84
- expect(Post).to have_received(:find_by_sql).once
85
- end
86
-
87
- it "auto eager loads belongs_to associations" do
88
- posts = Post.order(:title).to_a
89
-
90
- # Sanity check that associations aren't loaded yet
91
- posts.each do |blog|
92
- expect(blog.association(:blog)).to_not be_loaded
93
- end
94
-
95
- # Force the first post's blog to load
96
- posts.first.blog
97
-
98
- posts.each do |blog|
99
- expect(blog.association(:blog)).to be_loaded
100
- end
101
-
102
- expect(posts.map(&:blog).map(&:name)).to eq(['blog1', 'blog1', 'blog2', 'blog2'])
103
- expect(Blog).to have_received(:find_by_sql).once
104
- end
105
-
106
- it "auto eager loads has_one associations" do
107
- users = User.order(:name).to_a
108
-
109
- # Sanity check that associations aren't loaded yet
110
- users.each do |user|
111
- expect(user.association(:address)).to_not be_loaded
112
- end
113
-
114
- # Force the first user's address to load
115
- users.first.address
116
-
117
- users.each do |blog|
118
- expect(blog.association(:address)).to be_loaded
119
- end
120
-
121
- expect(users.map(&:address).map(&:city)).to match_array(['author1-city', 'author2-city', 'author3-city'])
122
- expect(Address).to have_received(:find_by_sql).once
123
- end
124
-
125
- it "auto eager loads nested associations" do
126
- blogs = Blog.order(:name).to_a
127
- blogs.first.posts.to_a.first.author
128
-
129
- blogs.flat_map(&:posts).each do |blog|
130
- expect(blog.association(:author)).to be_loaded
131
- end
132
-
133
- expect(blogs.first.posts.first.author).to eq author1
134
- expect(blogs.first.posts.second.author).to eq author2
135
- expect(blogs.second.posts.first.author).to eq author3
136
- expect(blogs.second.posts.second.author).to eq author1
137
- expect(Post).to have_received(:find_by_sql).once
138
- end
139
-
140
- it "auto eager loads has_many through associations" do
141
- blogs = Blog.order(:name).to_a
142
- blogs.first.authors.to_a
143
-
144
- blogs.each do |blog|
145
- expect(blog.association(:authors)).to be_loaded
146
- end
147
-
148
- expect(blogs.first.authors).to match_array([author1, author2])
149
- expect(blogs.second.authors).to match_array([author3, author1])
150
- expect(User).to have_received(:find_by_sql).once
151
- end
152
-
153
- it "auto eager loads nested has_many through associations" do
154
- blogs = Blog.order(:name).to_a
155
- blogs.first.addresses.to_a
156
-
157
- blogs.each do |blog|
158
- expect(blog.association(:addresses)).to be_loaded
159
- end
160
-
161
- expect(blogs.first.addresses).to match_array([author1, author2].map(&:address))
162
- expect(blogs.second.addresses).to match_array([author3, author1].map(&:address))
163
- expect(Address).to have_received(:find_by_sql).once
164
- end
165
-
166
- it "auto eager loads associations when the model is loaded via find" do
167
- blog = Blog.find(blog1.id)
168
- blog.posts.to_a.first.author
169
-
170
- blog.posts.each do |blog|
171
- expect(blog.association(:author)).to be_loaded
172
- end
173
- end
174
-
175
- it "auto eager loads polymorphic associations" do
176
- tags = Tag.where('parent_id IS NOT NULL').order(:name).to_a
177
- tags.first.owner
178
-
179
- tags.each do |tag|
180
- expect(tag.association(:owner)).to be_loaded
181
- end
182
-
183
- expect(tags.first.owner).to eq author1
184
- expect(tags.second.owner).to eq group1
185
- expect(tags.third.owner).to eq author2
186
- end
187
-
188
- it "auto eager loads associations of polymorphic associations" do
189
- tags = Tag.where('parent_id IS NOT NULL').order(:name).to_a
190
- users = tags.map(&:owner).select {|owner| owner.is_a?(User) }.sort_by(&:name)
191
- users.first.posts.to_a
192
-
193
- users.each do |user|
194
- expect(user.association(:posts)).to be_loaded
195
- end
196
-
197
- expect(users.first.posts).to eq Post.where(author_id: author1.id)
198
- expect(users.second.posts).to eq Post.where(author_id: author2.id)
199
- end
200
-
201
- it "only auto eager loads associations loaded through the same path" do
202
- root_tags = Tag.where(parent_id: nil).order(:name).to_a
203
- root_tags.first.children.to_a
204
-
205
- # Make sure we loaded all child tags
206
- root_tags.each do |tag|
207
- expect(tag.association(:children)).to be_loaded
208
- end
209
-
210
- # Force a load of a root tag's owner
211
- root_tags.first.owner
212
-
213
- # All root tag owners should be loaded
214
- root_tags.each do |tag|
215
- expect(tag.association(:owner)).to be_loaded
216
- end
217
-
218
- # Child tag owners should not be loaded
219
- child_tags = root_tags.flat_map(&:children)
220
- child_tags.each do |tag|
221
- expect(tag.association(:owner)).to_not be_loaded
222
- end
223
- end
224
-
225
- it "auto eager loads associations that have been overridden" do
226
- blogs = Blog.order(:name).to_a
227
-
228
- blogs.first.association(:posts_overridden).load_target
229
-
230
- blogs.each do |blog|
231
- expect(blog.association(:posts_overridden)).to be_loaded
232
- end
233
- end
234
-
235
- it "marks auto eager loaded models as read only when the association is read only" do
236
- blog = Blog.first!
237
- post = blog.read_only_posts.to_a.first
238
- expect { post.save! }.to raise_error(ActiveRecord::ReadOnlyRecord)
239
- end
240
-
241
- it "doesn't mark auto eager loaded models as read only when the association is not read only" do
242
- blog = Blog.first!
243
- post = blog.posts.to_a.first
244
- expect { post.save! }.to_not raise_error
245
- end
246
-
247
- context "with manual eager loading" do
248
- let(:blogs) { Blog.order(:name).send(load_method, :posts).to_a }
249
-
250
- before do
251
- blogs.first.posts.to_a.first.author
252
- end
253
-
254
- shared_examples "it auto-eager loads associations of manually eager loaded associations" do
255
- specify do
256
- blogs.flat_map(&:posts).drop(1).each do |blog|
257
- expect(blog.association(:author)).to be_loaded
258
- end
259
-
260
- expect(blogs.first.posts.first.author).to eq author1
261
- expect(blogs.first.posts.second.author).to eq author2
262
- expect(blogs.second.posts.first.author).to eq author3
263
- expect(blogs.second.posts.second.author).to eq author1
264
- expect(Post).to have_received(:find_by_sql).at_most(:once)
265
- end
266
- end
267
-
268
- context "via includes" do
269
- let(:load_method) { :includes }
270
-
271
- it_behaves_like "it auto-eager loads associations of manually eager loaded associations"
272
- end
273
-
274
- context "via eager_load" do
275
- let(:load_method) { :eager_load }
276
-
277
- it_behaves_like "it auto-eager loads associations of manually eager loaded associations"
278
- end
279
-
280
- context "via preload" do
281
- let(:load_method) { :preload }
282
-
283
- it_behaves_like "it auto-eager loads associations of manually eager loaded associations"
284
- end
285
- end
286
-
287
- context "with associations that can't be eager loaded" do
288
- let(:blogs) { Blog.order(:name).to_a }
289
-
290
- before do
291
- blog1.posts.create!(title: 'blog1-post3', author: author1)
292
- blog2.posts.create!(title: 'blog2-post3', author: author1)
293
- end
294
-
295
- shared_examples "it doesn't auto eager the association" do |association_name|
296
- specify do
297
- blogs.drop(1).each do |blog|
298
- expect(blog.association(association_name)).to_not be_loaded
299
- end
300
- end
301
- end
302
-
303
- context "associations with a limit" do
304
- before do
305
- blogs.first.limited_posts.to_a
306
- end
307
-
308
- it "applies the limit correctly" do
309
- expect(blogs.first.limited_posts.to_a.size).to eq 2
310
- end
311
-
312
- it_behaves_like "it doesn't auto eager the association", :limited_posts
313
- end
314
-
315
- context "associations with a group" do
316
- before do
317
- blogs.first.grouped_posts.to_a
318
- end
319
-
320
- it "applies the group correctly" do
321
- expect(blogs.first.grouped_posts.to_a.size).to eq 1
322
- end
323
-
324
- it_behaves_like "it doesn't auto eager the association", :grouped_posts
325
- end
326
-
327
- context "associations with an offset" do
328
- before do
329
- blogs.first.offset_posts.to_a
330
- end
331
-
332
- it "applies the offset correctly" do
333
- expect(blogs.first.offset_posts.to_a.size).to eq 1
334
- end
335
-
336
- it_behaves_like "it doesn't auto eager the association", :offset_posts
337
- end
338
-
339
- if ActiveRecord::VERSION::MAJOR >= 4
340
- context "associations with an overridden from" do
341
- before do
342
- blogs.first.from_posts.to_a
343
- end
344
-
345
- it "applies the from correctly" do
346
- expect(blogs.first.from_posts.to_a.size).to eq 1
347
- end
348
-
349
- it_behaves_like "it doesn't auto eager the association", :from_posts
350
- end
351
- end
352
-
353
- if Goldiloader::Compatibility.association_finder_sql_enabled?
354
- context "associations with finder_sql" do
355
- before do
356
- blogs.first.finder_sql_posts.to_a
357
- end
358
-
359
- it "applies the finder_sql correctly" do
360
- expect(blogs.first.finder_sql_posts.to_a.size).to eq 1
361
- end
362
-
363
- it_behaves_like "it doesn't auto eager the association", :finder_sql_posts
364
- end
365
- end
366
-
367
- if ActiveRecord::VERSION::MAJOR >= 4
368
- context "associations with a join" do
369
- before do
370
- blogs.first.posts_ordered_by_author.to_a
371
- end
372
-
373
- it "applies the join correctly" do
374
- expect(blogs.first.posts_ordered_by_author.to_a.size).to eq 3
375
- end
376
-
377
- it_behaves_like "it doesn't auto eager the association", :posts_ordered_by_author
378
- end
379
-
380
- context "associations with a join in a has_many_through" do
381
- before do
382
- blogs.first.authors_with_join.to_a
383
- end
384
-
385
- it "applies the join correctly" do
386
- expect(blogs.first.authors_with_join.to_a.size).to eq 3
387
- end
388
-
389
- it_behaves_like "it doesn't auto eager the association", :authors_with_join
390
- end
391
- end
392
-
393
- if Goldiloader::Compatibility.unscope_query_method_enabled?
394
- context "associations with an unscoped" do
395
- let(:authors) { User.order(:id).to_a }
396
-
397
- before do
398
- author1.address.update_attributes!(city: 'Boston')
399
- author2.address.update_attributes!(city: 'Philadelphia')
400
- author3.address.update_attributes!(city: 'Philadelphia')
401
- authors.first.scoped_address_with_default_scope_remove
402
- end
403
-
404
- it "applies the unscope correctly" do
405
- expect(authors.first.scoped_address_with_default_scope_remove).to be_present
406
- end
407
-
408
- it "doesn't auto eager the association" do
409
- authors.drop(1).each do |author|
410
- expect(author.association(:scoped_address_with_default_scope_remove)).to_not be_loaded
411
- end
412
- end
413
- end
414
- end
415
-
416
- if ActiveRecord::VERSION::MAJOR < 4
417
- context "unique_tags_has_and_belongs associations with a uniq" do
418
- let!(:post1) do
419
- Post.create! { |post| post.tags << child_tag1 << child_tag1 << child_tag3 }
420
- end
421
-
422
- let!(:post2) do
423
- Post.create! { |post| post.tags << child_tag1 << child_tag1 << child_tag2 }
424
- end
425
-
426
- let(:posts) { Post.where(id: [post1.id, post2.id]).order(:id).to_a }
427
-
428
- before do
429
- posts.first.unique_tags_has_and_belongs.to_a
430
- end
431
-
432
- it "applies the uniq correctly" do
433
- expect(posts.first.unique_tags_has_and_belongs.to_a.size).to eq 2
434
- end
435
-
436
- it "doesn't auto eager the association" do
437
- posts.drop(1).each do |author|
438
- expect(author.association(:unique_tags_has_and_belongs)).to_not be_loaded
439
- end
440
- end
441
- end
442
- end
443
-
444
- if ActiveRecord::VERSION::MAJOR >= 4
445
- context "associations with an instance dependent scope" do
446
- before do
447
- blogs.first.instance_dependent_posts.to_a
448
- end
449
-
450
- it "applies the scope correctly" do
451
- expect(blogs.first.instance_dependent_posts.to_a).to match_array(blogs.first.posts)
452
- end
453
-
454
- it_behaves_like "it doesn't auto eager the association", :instance_dependent_posts
455
- end
456
- end
457
- end
458
-
459
- context "associations with a uniq" do
460
- let!(:post1) do
461
- Post.create! { |post| post.tags << child_tag1 << child_tag1 << child_tag3 }
462
- end
463
-
464
- let!(:post2) do
465
- Post.create! { |post| post.tags << child_tag1 << child_tag1 << child_tag2 }
466
- end
467
-
468
- let(:posts) { Post.where(id: [post1.id, post2.id]).order(:id).to_a }
469
-
470
- before do
471
- posts.first.unique_tags.to_a
472
- end
473
-
474
- it "applies the uniq correctly" do
475
- expect(posts.first.unique_tags.to_a).to match_array([child_tag1, child_tag3])
476
- end
477
-
478
- it "auto eager loads the association" do
479
- posts.each do |blog|
480
- expect(blog.association(:unique_tags)).to be_loaded
481
- end
482
- end
483
- end
484
-
485
- context "polymorphic associations with nil" do
486
- let!(:user) { User.create! }
487
- let!(:group) { Group.create! }
488
-
489
- let!(:post1) do
490
- Post.create! { |post| post.owner = user }
491
- end
492
-
493
- let!(:post2) do
494
- Post.create! { |post| post.owner = group }
495
- end
496
-
497
- let!(:post3) do
498
- Post.create!
499
- end
500
-
501
- let(:posts) { Post.where(id: [post1, post2, post3].map(&:id)).order(:id).to_a }
502
-
503
- before do
504
- posts.first.owner
505
- end
506
-
507
- it "loads the association correctly" do
508
- expect(posts.map(&:owner)).to eq [user, group, nil]
509
- end
510
-
511
- it "auto eager loads the association" do
512
- posts.select(&:owner_id).each do |post|
513
- expect(post.association(:owner)).to be_loaded
514
- end
515
- end
516
- end
517
-
518
- context "when a model is destroyed" do
519
- let!(:posts) { Post.where(blog_id: blog1.id).to_a }
520
- let(:destroyed_post) { posts.first }
521
- let(:other_post) { posts.last }
522
-
523
- before do
524
- blog_after_destroy = nil
525
- destroyed_post.define_singleton_method(:after_post_destroy) do
526
- blog_after_destroy = self.blog
527
- end
528
- destroyed_post.destroy
529
- @blog_after_destroy = blog_after_destroy
530
- end
531
-
532
- it "can load associations in after_destroy callbacks" do
533
- expect(@blog_after_destroy).to eq blog1
534
- end
535
-
536
- it "auto eager loads the associaton on other models" do
537
- expect(other_post.association(:blog)).to be_loaded
538
- end
539
- end
540
-
541
- context "when a has_many association has in-memory changes" do
542
- let!(:blogs) { Blog.order(:name).to_a }
543
- let(:blog) { blogs.first }
544
- let(:other_blog) { blogs.last }
545
-
546
- before do
547
- blog.posts.create(title: 'blog1-new-post')
548
- end
549
-
550
- it "returns the correct models for the modified has_many association" do
551
- expect(blog.posts).to match_array Post.where(blog_id: blog.id)
552
- end
553
-
554
- it "doesn't auto eager load peers when accessing the modified has_many association" do
555
- blog.posts.to_a
556
- expect(other_blog.association(:posts)).to_not be_loaded
557
- end
558
-
559
- it "returns the correct models for the modified has_many association when accessing a peer" do
560
- other_blog.posts.to_a
561
- expect(blog.posts).to match_array Post.where(blog_id: blog.id)
562
- end
563
- end
564
-
565
- context "when a has_many through association has in-memory changes" do
566
- let!(:posts) { Post.order(:title).to_a }
567
- let(:post) { posts.first }
568
- let(:other_post) { posts.last }
569
-
570
- before do
571
- tag = Tag.create(name: 'new-tag')
572
- post.post_tags.create(tag: tag)
573
- end
574
-
575
- it "returns the correct models for the modified has_many through association" do
576
- expect(post.tags).to match_array PostTag.where(post_id: post.id).includes(:tag).map(&:tag)
577
- end
578
-
579
- it "doesn't auto eager load peers when accessing the modified has_many through association" do
580
- post.tags.to_a
581
- expect(other_post.association(:tags)).to_not be_loaded
582
- end
583
-
584
- it "returns the correct models for the modified has_many through association when accessing a peer" do
585
- other_post.tags.to_a
586
- expect(post.tags).to match_array PostTag.where(post_id: post.id).includes(:tag).map(&:tag)
587
- end
588
- end
589
-
590
- context "with fully_load false" do
591
-
592
- it "doesn't auto eager loads a has_many association when size is called" do
593
- blogs = Blog.order(:name).to_a
594
- blogs.first.posts.size
595
-
596
- blogs.each do |blog|
597
- expect(blog.association(:posts)).to_not be_loaded
598
- end
599
- end
600
-
601
- it "doesn't auto eager loads a has_many association when exists? is called" do
602
- blogs = Blog.order(:name).to_a
603
- blogs.first.posts.exists?
604
-
605
- blogs.each do |blog|
606
- expect(blog.association(:posts)).to_not be_loaded
607
- end
608
- end
609
-
610
- it "doesn't auto eager loads a has_many association when last is called" do
611
- blogs = Blog.order(:name).to_a
612
- blogs.first.posts.last
613
-
614
- blogs.each do |blog|
615
- expect(blog.association(:posts)).to_not be_loaded
616
- end
617
- end
618
-
619
- it "doesn't auto eager loads a has_many association when ids is called" do
620
- blogs = Blog.order(:name).to_a
621
- blogs.first.post_ids
622
-
623
- blogs.each do |blog|
624
- expect(blog.association(:posts)).to_not be_loaded
625
- end
626
- end
627
- end
628
-
629
- context "with fully_load true" do
630
-
631
- it "auto eager loads a has_many association when size is called" do
632
- blogs = Blog.order(:name).to_a
633
- blogs.first.posts_fully_load.size
634
-
635
- blogs.each do |blog|
636
- expect(blog.association(:posts_fully_load)).to be_loaded
637
- end
638
- end
639
-
640
- it "auto eager loads a has_many association when exists? is called" do
641
- blogs = Blog.order(:name).to_a
642
- blogs.first.posts_fully_load.exists?
643
-
644
- blogs.each do |blog|
645
- expect(blog.association(:posts_fully_load)).to be_loaded
646
- end
647
- end
648
-
649
- it "doesn't auto eager load a has_many association when exists? is called with arguments" do
650
- blogs = Blog.order(:name).to_a
651
- blogs.first.posts_fully_load.exists?(false)
652
-
653
- blogs.each do |blog|
654
- expect(blog.association(:posts_fully_load)).to_not be_loaded
655
- end
656
- end
657
-
658
- it "auto eager loads a has_many association when last is called" do
659
- blogs = Blog.order(:name).to_a
660
- blogs.first.posts_fully_load.last
661
-
662
- blogs.each do |blog|
663
- expect(blog.association(:posts_fully_load)).to be_loaded
664
- end
665
- end
666
-
667
- it "auto eager loads a has_many association when ids is called" do
668
- blogs = Blog.order(:name).to_a
669
- blogs.first.posts_fully_load_ids
670
-
671
- blogs.each do |blog|
672
- expect(blog.association(:posts_fully_load)).to be_loaded
673
- end
674
- end
675
-
676
- end
677
-
678
- context "with auto_include disabled" do
679
-
680
- it "doesn't auto eager load has_many associations" do
681
- blogs = Blog.order(:name).to_a
682
-
683
- # Force the first blogs first post to load
684
- posts = blogs.first.posts_without_auto_include.to_a
685
- expect(posts).to match_array Post.where(blog_id: blogs.first.id)
686
-
687
- blogs.drop(1).each do |blog|
688
- expect(blog.association(:posts_without_auto_include)).to_not be_loaded
689
- end
690
- end
691
-
692
- it "doesn't auto eager load has_one associations" do
693
- users = User.order(:name).to_a
694
-
695
- # Force the first user's address to load
696
- user = users.first
697
- address = user.address_without_auto_include
698
- expect(address).to eq Address.where(user_id: user.id).first
699
-
700
- users.drop(1).each do |blog|
701
- expect(blog.association(:address_without_auto_include)).to_not be_loaded
702
- end
703
- end
704
-
705
- it "doesn't auto eager load belongs_to associations" do
706
- posts = Post.order(:title).to_a
707
- # Force the first post's blog to load
708
- post = posts.first
709
- blog = post.blog_without_auto_include
710
- expect(blog).to eq Blog.where(id: post.blog_id).first
711
-
712
- posts.drop(1).each do |blog|
713
- expect(blog.association(:blog_without_auto_include)).to_not be_loaded
714
- end
715
- end
716
-
717
- it "still auto eager loads nested associations" do
718
- posts = Post.order(:title).to_a
719
- # Force the first post's blog to load
720
- blog = posts.first.blog_without_auto_include
721
-
722
- # Load another blogs posts
723
- other_blog = posts.last.blog_without_auto_include
724
- other_blog.posts.to_a
725
-
726
- blog.posts.to_a.first.tags.to_a
727
-
728
- blog.posts.each do |post|
729
- expect(post.association(:tags)).to be_loaded
730
- end
731
-
732
- other_blog.posts.each do |post|
733
- expect(post.association(:tags)).to_not be_loaded
734
- end
735
- end
736
- end
737
- end