bullet 5.7.0 → 5.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile.rails-5.2 +1 -1
- data/Guardfile +1 -1
- data/README.md +3 -0
- data/Rakefile +4 -4
- data/bullet.gemspec +2 -3
- data/lib/bullet.rb +23 -23
- data/lib/bullet/active_record4.rb +3 -1
- data/lib/bullet/active_record41.rb +1 -1
- data/lib/bullet/active_record42.rb +8 -9
- data/lib/bullet/active_record5.rb +27 -28
- data/lib/bullet/active_record52.rb +27 -28
- data/lib/bullet/detector/association.rb +12 -12
- data/lib/bullet/detector/counter_cache.rb +7 -7
- data/lib/bullet/detector/n_plus_one_query.rb +6 -6
- data/lib/bullet/detector/unused_eager_loading.rb +23 -21
- data/lib/bullet/ext/object.rb +4 -4
- data/lib/bullet/ext/string.rb +1 -1
- data/lib/bullet/notification/base.rb +14 -14
- data/lib/bullet/notification/n_plus_one_query.rb +4 -4
- data/lib/bullet/notification/unused_eager_loading.rb +4 -4
- data/lib/bullet/notification_collector.rb +0 -1
- data/lib/bullet/version.rb +1 -2
- data/perf/benchmark.rb +7 -7
- data/spec/bullet/detector/n_plus_one_query_spec.rb +8 -8
- data/spec/bullet/ext/object_spec.rb +1 -1
- data/spec/bullet/notification/base_spec.rb +6 -6
- data/spec/bullet/notification/counter_cache_spec.rb +1 -1
- data/spec/bullet/notification/n_plus_one_query_spec.rb +1 -1
- data/spec/bullet/notification/unused_eager_loading_spec.rb +1 -1
- data/spec/bullet/rack_spec.rb +9 -10
- data/spec/bullet/registry/association_spec.rb +2 -2
- data/spec/bullet/registry/base_spec.rb +3 -3
- data/spec/bullet_spec.rb +7 -7
- data/spec/integration/active_record/association_spec.rb +16 -16
- data/spec/integration/counter_cache_spec.rb +2 -2
- data/spec/models/mongoid/address.rb +1 -1
- data/spec/models/mongoid/category.rb +2 -2
- data/spec/models/mongoid/comment.rb +1 -1
- data/spec/models/mongoid/company.rb +1 -1
- data/spec/models/mongoid/entry.rb +1 -1
- data/spec/models/mongoid/post.rb +4 -4
- data/spec/spec_helper.rb +1 -1
- data/spec/support/mongo_seed.rb +23 -23
- data/spec/support/rack_double.rb +7 -16
- data/spec/support/sqlite_seed.rb +73 -73
- metadata +5 -5
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module Bullet
|
4
4
|
module Notification
|
5
5
|
describe CounterCache do
|
6
|
-
subject { CounterCache.new(Post, [
|
6
|
+
subject { CounterCache.new(Post, %i[comments votes]) }
|
7
7
|
|
8
8
|
it { expect(subject.body).to eq(' Post => [:comments, :votes]') }
|
9
9
|
it { expect(subject.title).to eq('Need Counter Cache') }
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module Bullet
|
4
4
|
module Notification
|
5
5
|
describe NPlusOneQuery do
|
6
|
-
subject { NPlusOneQuery.new([[
|
6
|
+
subject { NPlusOneQuery.new([%w[caller1 caller2]], Post, %i[comments votes], 'path') }
|
7
7
|
|
8
8
|
it { expect(subject.body_with_caller).to eq(" Post => [:comments, :votes]\n Add to your finder: :includes => [:comments, :votes]\nCall stack\n caller1\n caller2\n") }
|
9
9
|
it { expect([subject.body_with_caller, subject.body_with_caller]).to eq([" Post => [:comments, :votes]\n Add to your finder: :includes => [:comments, :votes]\nCall stack\n caller1\n caller2\n", " Post => [:comments, :votes]\n Add to your finder: :includes => [:comments, :votes]\nCall stack\n caller1\n caller2\n"]) }
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module Bullet
|
4
4
|
module Notification
|
5
5
|
describe UnusedEagerLoading do
|
6
|
-
subject { UnusedEagerLoading.new([''], Post, [
|
6
|
+
subject { UnusedEagerLoading.new([''], Post, %i[comments votes], 'path') }
|
7
7
|
|
8
8
|
it { expect(subject.body).to eq(" Post => [:comments, :votes]\n Remove from your finder: :includes => [:comments, :votes]") }
|
9
9
|
it { expect(subject.title).to eq('AVOID eager loading in path') }
|
data/spec/bullet/rack_spec.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
3
|
module Bullet
|
@@ -9,38 +8,38 @@ module Bullet
|
|
9
8
|
context '#html_request?' do
|
10
9
|
it 'should be true if Content-Type is text/html and http body contains html tag' do
|
11
10
|
headers = { 'Content-Type' => 'text/html' }
|
12
|
-
response = double(:
|
11
|
+
response = double(body: '<html><head></head><body></body></html>')
|
13
12
|
expect(middleware).to be_html_request(headers, response)
|
14
13
|
end
|
15
14
|
|
16
15
|
it 'should be true if Content-Type is text/html and http body contains html tag with attributes' do
|
17
16
|
headers = { 'Content-Type' => 'text/html' }
|
18
|
-
response = double(:
|
17
|
+
response = double(body: "<html attr='hello'><head></head><body></body></html>")
|
19
18
|
expect(middleware).to be_html_request(headers, response)
|
20
19
|
end
|
21
20
|
|
22
21
|
it 'should be false if there is no Content-Type header' do
|
23
22
|
headers = {}
|
24
|
-
response = double(:
|
23
|
+
response = double(body: '<html><head></head><body></body></html>')
|
25
24
|
expect(middleware).not_to be_html_request(headers, response)
|
26
25
|
end
|
27
26
|
|
28
27
|
it 'should be false if Content-Type is javascript' do
|
29
28
|
headers = { 'Content-Type' => 'text/javascript' }
|
30
|
-
response = double(:
|
29
|
+
response = double(body: '<html><head></head><body></body></html>')
|
31
30
|
expect(middleware).not_to be_html_request(headers, response)
|
32
31
|
end
|
33
32
|
|
34
33
|
it "should be false if response body doesn't contain html tag" do
|
35
34
|
headers = { 'Content-Type' => 'text/html' }
|
36
|
-
response = double(:
|
35
|
+
response = double(body: '<div>Partial</div>')
|
37
36
|
expect(middleware).not_to be_html_request(headers, response)
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
40
|
context 'empty?' do
|
42
41
|
it 'should be false if response is a string and not empty' do
|
43
|
-
response = double(:
|
42
|
+
response = double(body: '<html><head></head><body></body></html>')
|
44
43
|
expect(middleware).not_to be_empty(response)
|
45
44
|
end
|
46
45
|
|
@@ -50,7 +49,7 @@ module Bullet
|
|
50
49
|
end
|
51
50
|
|
52
51
|
it 'should be true if response body is empty' do
|
53
|
-
response = double(:
|
52
|
+
response = double(body: '')
|
54
53
|
expect(middleware).to be_empty(response)
|
55
54
|
end
|
56
55
|
end
|
@@ -68,7 +67,7 @@ module Bullet
|
|
68
67
|
expect(Bullet).to receive(:notification?).and_return(true)
|
69
68
|
expect(Bullet).to receive(:gather_inline_notifications).and_return('<bullet></bullet>')
|
70
69
|
expect(Bullet).to receive(:perform_out_of_channel_notifications)
|
71
|
-
status, headers, response = middleware.call(
|
70
|
+
status, headers, response = middleware.call('Content-Type' => 'text/html')
|
72
71
|
expect(headers['Content-Length']).to eq('56')
|
73
72
|
expect(response).to eq(['<html><head></head><body><bullet></bullet></body></html>'])
|
74
73
|
end
|
@@ -79,7 +78,7 @@ module Bullet
|
|
79
78
|
app.response = response
|
80
79
|
expect(Bullet).to receive(:notification?).and_return(true)
|
81
80
|
expect(Bullet).to receive(:gather_inline_notifications).and_return('<bullet></bullet>')
|
82
|
-
status, headers, response = middleware.call(
|
81
|
+
status, headers, response = middleware.call('Content-Type' => 'text/html')
|
83
82
|
expect(headers['Content-Length']).to eq('58')
|
84
83
|
end
|
85
84
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module Bullet
|
4
4
|
module Registry
|
5
5
|
describe Association do
|
6
|
-
subject { Association.new.tap { |association| association.add([
|
6
|
+
subject { Association.new.tap { |association| association.add(%w[key1 key2], 'value') } }
|
7
7
|
|
8
8
|
context '#merge' do
|
9
9
|
it 'should merge key/value' do
|
@@ -14,7 +14,7 @@ module Bullet
|
|
14
14
|
|
15
15
|
context '#similarly_associated' do
|
16
16
|
it 'should return similarly associated keys' do
|
17
|
-
expect(subject.similarly_associated('key1', Set.new(['value']))).to eq([
|
17
|
+
expect(subject.similarly_associated('key1', Set.new(['value']))).to eq(%w[key1 key2])
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should return empty if key does not exist' do
|
@@ -21,12 +21,12 @@ module Bullet
|
|
21
21
|
context '#add' do
|
22
22
|
it 'should add value with string' do
|
23
23
|
subject.add('key', 'new_value')
|
24
|
-
expect(subject['key']).to eq(Set.new([
|
24
|
+
expect(subject['key']).to eq(Set.new(%w[value new_value]))
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should add value with array' do
|
28
|
-
subject.add('key', [
|
29
|
-
expect(subject['key']).to eq(Set.new([
|
28
|
+
subject.add('key', %w[value1 value2])
|
29
|
+
expect(subject['key']).to eq(Set.new(%w[value value1 value2]))
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
data/spec/bullet_spec.rb
CHANGED
@@ -88,7 +88,7 @@ describe Bullet, focused: true do
|
|
88
88
|
describe '#add_whitelist' do
|
89
89
|
context "for 'special' class names" do
|
90
90
|
it 'is added to the whitelist successfully' do
|
91
|
-
Bullet.add_whitelist(:
|
91
|
+
Bullet.add_whitelist(type: :n_plus_one_query, class_name: 'Klass', association: :department)
|
92
92
|
expect(Bullet.get_whitelist_associations(:n_plus_one_query, 'Klass')).to include :department
|
93
93
|
end
|
94
94
|
end
|
@@ -97,17 +97,17 @@ describe Bullet, focused: true do
|
|
97
97
|
describe '#delete_whitelist' do
|
98
98
|
context "for 'special' class names" do
|
99
99
|
it 'is deleted from the whitelist successfully' do
|
100
|
-
Bullet.add_whitelist(:
|
101
|
-
Bullet.delete_whitelist(:
|
100
|
+
Bullet.add_whitelist(type: :n_plus_one_query, class_name: 'Klass', association: :department)
|
101
|
+
Bullet.delete_whitelist(type: :n_plus_one_query, class_name: 'Klass', association: :department)
|
102
102
|
expect(Bullet.whitelist[:n_plus_one_query]).to eq({})
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
context 'when exists multiple definitions' do
|
107
107
|
it 'is deleted from the whitelist successfully' do
|
108
|
-
Bullet.add_whitelist(:
|
109
|
-
Bullet.add_whitelist(:
|
110
|
-
Bullet.delete_whitelist(:
|
108
|
+
Bullet.add_whitelist(type: :n_plus_one_query, class_name: 'Klass', association: :department)
|
109
|
+
Bullet.add_whitelist(type: :n_plus_one_query, class_name: 'Klass', association: :team)
|
110
|
+
Bullet.delete_whitelist(type: :n_plus_one_query, class_name: 'Klass', association: :team)
|
111
111
|
expect(Bullet.get_whitelist_associations(:n_plus_one_query, 'Klass')).to include :department
|
112
112
|
expect(Bullet.get_whitelist_associations(:n_plus_one_query, 'Klass')).to_not include :team
|
113
113
|
end
|
@@ -127,7 +127,7 @@ describe Bullet, focused: true do
|
|
127
127
|
{
|
128
128
|
'REQUEST_METHOD' => 'GET',
|
129
129
|
'PATH_INFO' => '/path',
|
130
|
-
'QUERY_STRING' => 'foo=bar'
|
130
|
+
'QUERY_STRING' => 'foo=bar'
|
131
131
|
}
|
132
132
|
}
|
133
133
|
|
@@ -122,7 +122,7 @@ if active_record?
|
|
122
122
|
end
|
123
123
|
|
124
124
|
it 'should detect preload with category => posts => comments' do
|
125
|
-
Category.includes(
|
125
|
+
Category.includes(posts: :comments).each do |category|
|
126
126
|
category.posts.each do |post|
|
127
127
|
post.comments.map(&:name)
|
128
128
|
end
|
@@ -134,7 +134,7 @@ if active_record?
|
|
134
134
|
end
|
135
135
|
|
136
136
|
it 'should detect preload with category => posts => comments with posts.id > 0' do
|
137
|
-
Category.includes(
|
137
|
+
Category.includes(posts: :comments).where('posts.id > 0').references(:posts).each do |category|
|
138
138
|
category.posts.each do |post|
|
139
139
|
post.comments.map(&:name)
|
140
140
|
end
|
@@ -146,7 +146,7 @@ if active_record?
|
|
146
146
|
end
|
147
147
|
|
148
148
|
it 'should detect unused preload with category => posts => comments' do
|
149
|
-
Category.includes(
|
149
|
+
Category.includes(posts: :comments).map(&:name)
|
150
150
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
151
151
|
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Post, :comments)
|
152
152
|
|
@@ -154,7 +154,7 @@ if active_record?
|
|
154
154
|
end
|
155
155
|
|
156
156
|
it 'should detect unused preload with post => commnets, no category => posts' do
|
157
|
-
Category.includes(
|
157
|
+
Category.includes(posts: :comments).each do |category|
|
158
158
|
category.posts.map(&:name)
|
159
159
|
end
|
160
160
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
@@ -190,7 +190,7 @@ if active_record?
|
|
190
190
|
end
|
191
191
|
|
192
192
|
it 'should detect preload with category => [posts, entries]' do
|
193
|
-
Category.includes([
|
193
|
+
Category.includes(%i[posts entries]).each do |category|
|
194
194
|
category.posts.map(&:name)
|
195
195
|
category.entries.map(&:name)
|
196
196
|
end
|
@@ -201,7 +201,7 @@ if active_record?
|
|
201
201
|
end
|
202
202
|
|
203
203
|
it 'should detect unused preload with category => [posts, entries]' do
|
204
|
-
Category.includes([
|
204
|
+
Category.includes(%i[posts entries]).map(&:name)
|
205
205
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
206
206
|
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Category, :posts)
|
207
207
|
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Category, :entries)
|
@@ -210,7 +210,7 @@ if active_record?
|
|
210
210
|
end
|
211
211
|
|
212
212
|
it 'should detect unused preload with category => entries, but not with category => posts' do
|
213
|
-
Category.includes([
|
213
|
+
Category.includes(%i[posts entries]).each do |category|
|
214
214
|
category.posts.map(&:name)
|
215
215
|
end
|
216
216
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
@@ -257,7 +257,7 @@ if active_record?
|
|
257
257
|
|
258
258
|
context 'category => posts => writer' do
|
259
259
|
it 'should not detect unused preload associations' do
|
260
|
-
category = Category.includes(
|
260
|
+
category = Category.includes(posts: :writer).order('id DESC').find_by_name('first')
|
261
261
|
category.posts.map do |post|
|
262
262
|
post.name
|
263
263
|
post.writer.name
|
@@ -387,7 +387,7 @@ if active_record?
|
|
387
387
|
end
|
388
388
|
|
389
389
|
it 'should not detect unpreload association' do
|
390
|
-
Comment.includes(:
|
390
|
+
Comment.includes(post: :category).each do |comment|
|
391
391
|
comment.post.category.name
|
392
392
|
end
|
393
393
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
@@ -399,7 +399,7 @@ if active_record?
|
|
399
399
|
|
400
400
|
context 'comment => author, post => writer' do
|
401
401
|
it 'should detect non preloaded writer' do
|
402
|
-
Comment.includes([
|
402
|
+
Comment.includes(%i[author post]).where(['base_users.id = ?', BaseUser.first]).references(:base_users).each do |comment|
|
403
403
|
comment.post.writer.name
|
404
404
|
end
|
405
405
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
@@ -409,7 +409,7 @@ if active_record?
|
|
409
409
|
end
|
410
410
|
|
411
411
|
it 'should detect unused preload with comment => author' do
|
412
|
-
Comment.includes([:author, { :
|
412
|
+
Comment.includes([:author, { post: :writer }]).where(['base_users.id = ?', BaseUser.first]).references(:base_users).each do |comment|
|
413
413
|
comment.post.writer.name
|
414
414
|
end
|
415
415
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
@@ -419,7 +419,7 @@ if active_record?
|
|
419
419
|
end
|
420
420
|
|
421
421
|
it 'should detect non preloading with writer => newspaper' do
|
422
|
-
Comment.includes(:
|
422
|
+
Comment.includes(post: :writer).where("posts.name like '%first%'").references(:posts).each do |comment|
|
423
423
|
comment.post.writer.newspaper.name
|
424
424
|
end
|
425
425
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
@@ -430,10 +430,10 @@ if active_record?
|
|
430
430
|
|
431
431
|
it 'should not raise a stack error from posts to category' do
|
432
432
|
expect {
|
433
|
-
Comment.includes(
|
433
|
+
Comment.includes(post: :category).each do |com|
|
434
434
|
com.post.category
|
435
435
|
end
|
436
|
-
}.not_to raise_error
|
436
|
+
}.not_to raise_error
|
437
437
|
end
|
438
438
|
end
|
439
439
|
end
|
@@ -720,7 +720,7 @@ if active_record?
|
|
720
720
|
end
|
721
721
|
|
722
722
|
context 'whitelist n plus one query' do
|
723
|
-
before { Bullet.add_whitelist :
|
723
|
+
before { Bullet.add_whitelist type: :n_plus_one_query, class_name: 'Post', association: :comments }
|
724
724
|
after { Bullet.clear_whitelist }
|
725
725
|
|
726
726
|
it 'should not detect n plus one query' do
|
@@ -743,7 +743,7 @@ if active_record?
|
|
743
743
|
end
|
744
744
|
|
745
745
|
context 'whitelist unused eager loading' do
|
746
|
-
before { Bullet.add_whitelist :
|
746
|
+
before { Bullet.add_whitelist type: :unused_eager_loading, class_name: 'Post', association: :comments }
|
747
747
|
after { Bullet.clear_whitelist }
|
748
748
|
|
749
749
|
it 'should not detect unused eager loading' do
|
@@ -54,7 +54,7 @@ if !mongoid? && active_record?
|
|
54
54
|
|
55
55
|
it 'should not need counter cache with part of cities' do
|
56
56
|
Country.all.each do |country|
|
57
|
-
country.cities.where(:
|
57
|
+
country.cities.where(name: 'first').size
|
58
58
|
end
|
59
59
|
expect(Bullet.collected_counter_cache_notifications).to be_empty
|
60
60
|
end
|
@@ -72,7 +72,7 @@ if !mongoid? && active_record?
|
|
72
72
|
end
|
73
73
|
|
74
74
|
context 'whitelist' do
|
75
|
-
before { Bullet.add_whitelist :
|
75
|
+
before { Bullet.add_whitelist type: :counter_cache, class_name: 'Country', association: :cities }
|
76
76
|
after { Bullet.clear_whitelist }
|
77
77
|
|
78
78
|
it 'should not detect counter cache' do
|
data/spec/models/mongoid/post.rb
CHANGED
@@ -3,10 +3,10 @@ class Mongoid::Post
|
|
3
3
|
|
4
4
|
field :name
|
5
5
|
|
6
|
-
has_many :comments, :
|
7
|
-
belongs_to :category, :
|
6
|
+
has_many :comments, class_name: 'Mongoid::Comment'
|
7
|
+
belongs_to :category, class_name: 'Mongoid::Category'
|
8
8
|
|
9
|
-
embeds_many :users, :
|
9
|
+
embeds_many :users, class_name: 'Mongoid::User'
|
10
10
|
|
11
|
-
scope :preload_comments,
|
11
|
+
scope :preload_comments, -> { includes(:comments) }
|
12
12
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -33,7 +33,7 @@ Dir[File.join(SUPPORT, '*.rb')].reject { |filename| filename =~ /_seed.rb$/ }.so
|
|
33
33
|
RSpec.configure do |config|
|
34
34
|
config.extend Bullet::Dependency
|
35
35
|
|
36
|
-
config.filter_run :
|
36
|
+
config.filter_run focus: true
|
37
37
|
config.run_all_when_everything_filtered = true
|
38
38
|
end
|
39
39
|
|
data/spec/support/mongo_seed.rb
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
module Support
|
2
2
|
module MongoSeed
|
3
3
|
def seed_db
|
4
|
-
category1 = Mongoid::Category.create(:
|
5
|
-
category2 = Mongoid::Category.create(:
|
4
|
+
category1 = Mongoid::Category.create(name: 'first')
|
5
|
+
category2 = Mongoid::Category.create(name: 'second')
|
6
6
|
|
7
|
-
post1 = category1.posts.create(:
|
8
|
-
post1a = category1.posts.create(:
|
9
|
-
post2 = category2.posts.create(:
|
7
|
+
post1 = category1.posts.create(name: 'first')
|
8
|
+
post1a = category1.posts.create(name: 'like first')
|
9
|
+
post2 = category2.posts.create(name: 'second')
|
10
10
|
|
11
|
-
post1.users << Mongoid::User.create(:
|
12
|
-
post1.users << Mongoid::User.create(:
|
13
|
-
post2.users << Mongoid::User.create(:
|
11
|
+
post1.users << Mongoid::User.create(name: 'first')
|
12
|
+
post1.users << Mongoid::User.create(name: 'another')
|
13
|
+
post2.users << Mongoid::User.create(name: 'second')
|
14
14
|
|
15
|
-
comment1 = post1.comments.create(:
|
16
|
-
comment2 = post1.comments.create(:
|
17
|
-
comment3 = post1.comments.create(:
|
18
|
-
comment4 = post1.comments.create(:
|
19
|
-
comment8 = post1a.comments.create(:
|
20
|
-
comment9 = post1a.comments.create(:
|
21
|
-
comment5 = post2.comments.create(:
|
22
|
-
comment6 = post2.comments.create(:
|
23
|
-
comment7 = post2.comments.create(:
|
15
|
+
comment1 = post1.comments.create(name: 'first')
|
16
|
+
comment2 = post1.comments.create(name: 'first2')
|
17
|
+
comment3 = post1.comments.create(name: 'first3')
|
18
|
+
comment4 = post1.comments.create(name: 'second')
|
19
|
+
comment8 = post1a.comments.create(name: 'like first 1')
|
20
|
+
comment9 = post1a.comments.create(name: 'like first 2')
|
21
|
+
comment5 = post2.comments.create(name: 'third')
|
22
|
+
comment6 = post2.comments.create(name: 'fourth')
|
23
|
+
comment7 = post2.comments.create(name: 'fourth')
|
24
24
|
|
25
|
-
entry1 = category1.entries.create(:
|
26
|
-
entry2 = category1.entries.create(:
|
25
|
+
entry1 = category1.entries.create(name: 'first')
|
26
|
+
entry2 = category1.entries.create(name: 'second')
|
27
27
|
|
28
|
-
company1 = Mongoid::Company.create(:
|
29
|
-
company2 = Mongoid::Company.create(:
|
28
|
+
company1 = Mongoid::Company.create(name: 'first')
|
29
|
+
company2 = Mongoid::Company.create(name: 'second')
|
30
30
|
|
31
|
-
Mongoid::Address.create(:
|
32
|
-
Mongoid::Address.create(:
|
31
|
+
Mongoid::Address.create(name: 'first', company: company1)
|
32
|
+
Mongoid::Address.create(name: 'second', company: company2)
|
33
33
|
end
|
34
34
|
|
35
35
|
def setup_db
|