bullet 6.1.3 → 7.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +82 -0
- data/CHANGELOG.md +27 -0
- data/Gemfile.rails-7.0 +10 -0
- data/README.md +30 -25
- data/lib/bullet/active_record41.rb +1 -0
- data/lib/bullet/active_record42.rb +1 -0
- data/lib/bullet/active_record52.rb +11 -17
- data/lib/bullet/active_record60.rb +11 -17
- data/lib/bullet/active_record61.rb +11 -17
- data/lib/bullet/active_record70.rb +275 -0
- data/lib/bullet/bullet_xhr.js +3 -2
- data/lib/bullet/dependency.rb +10 -0
- data/lib/bullet/detector/base.rb +2 -1
- data/lib/bullet/detector/counter_cache.rb +1 -1
- data/lib/bullet/detector/n_plus_one_query.rb +3 -3
- data/lib/bullet/detector/unused_eager_loading.rb +1 -1
- data/lib/bullet/mongoid7x.rb +26 -9
- data/lib/bullet/notification.rb +2 -1
- data/lib/bullet/rack.rb +7 -4
- data/lib/bullet/stack_trace_filter.rb +7 -8
- data/lib/bullet/version.rb +1 -1
- data/lib/bullet.rb +23 -24
- data/lib/generators/bullet/install_generator.rb +0 -1
- data/perf/benchmark.rb +4 -1
- data/spec/bullet/detector/unused_eager_loading_spec.rb +6 -2
- data/spec/bullet/ext/object_spec.rb +1 -1
- data/spec/bullet/notification/base_spec.rb +4 -4
- data/spec/bullet/rack_spec.rb +90 -19
- data/spec/bullet_spec.rb +15 -15
- data/spec/integration/active_record/association_spec.rb +27 -8
- data/spec/integration/counter_cache_spec.rb +4 -4
- data/spec/integration/mongoid/association_spec.rb +1 -1
- data/spec/models/deal.rb +5 -0
- data/spec/models/folder.rb +2 -1
- data/spec/models/group.rb +2 -1
- data/spec/models/page.rb +2 -1
- data/spec/models/post.rb +2 -0
- data/spec/models/role.rb +7 -0
- data/spec/models/user.rb +1 -0
- data/spec/models/writer.rb +2 -1
- data/spec/spec_helper.rb +0 -2
- data/spec/support/mongo_seed.rb +1 -0
- data/spec/support/sqlite_seed.rb +30 -0
- data/test.sh +2 -0
- metadata +10 -4
- data/.travis.yml +0 -33
@@ -10,7 +10,7 @@ describe Object do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
if mongoid?
|
13
|
-
it 'should return class with
|
13
|
+
it 'should return class with namespace and id composition' do
|
14
14
|
post = Mongoid::Post.first
|
15
15
|
expect(post.bullet_key).to eq("Mongoid::Post:#{post.id}")
|
16
16
|
end
|
@@ -74,8 +74,8 @@ module Bullet
|
|
74
74
|
it 'should send full_notice to notifier' do
|
75
75
|
notifier = double
|
76
76
|
allow(subject).to receive(:notifier).and_return(notifier)
|
77
|
-
allow(subject).to receive(:notification_data).and_return(foo: :bar)
|
78
|
-
expect(notifier).to receive(:inline_notify).with(foo: :bar)
|
77
|
+
allow(subject).to receive(:notification_data).and_return({ foo: :bar })
|
78
|
+
expect(notifier).to receive(:inline_notify).with({ foo: :bar })
|
79
79
|
subject.notify_inline
|
80
80
|
end
|
81
81
|
end
|
@@ -84,8 +84,8 @@ module Bullet
|
|
84
84
|
it 'should send full_out_of_channel to notifier' do
|
85
85
|
notifier = double
|
86
86
|
allow(subject).to receive(:notifier).and_return(notifier)
|
87
|
-
allow(subject).to receive(:notification_data).and_return(foo: :bar)
|
88
|
-
expect(notifier).to receive(:out_of_channel_notify).with(foo: :bar)
|
87
|
+
allow(subject).to receive(:notification_data).and_return({ foo: :bar })
|
88
|
+
expect(notifier).to receive(:out_of_channel_notify).with({ foo: :bar })
|
89
89
|
subject.notify_out_of_channel
|
90
90
|
end
|
91
91
|
end
|
data/spec/bullet/rack_spec.rb
CHANGED
@@ -31,12 +31,6 @@ module Bullet
|
|
31
31
|
response = double(body: '<html><head></head><body></body></html>')
|
32
32
|
expect(middleware).not_to be_html_request(headers, response)
|
33
33
|
end
|
34
|
-
|
35
|
-
it "should be false if response body doesn't contain html tag" do
|
36
|
-
headers = { 'Content-Type' => 'text/html' }
|
37
|
-
response = double(body: '<div>Partial</div>')
|
38
|
-
expect(middleware).not_to be_html_request(headers, response)
|
39
|
-
end
|
40
34
|
end
|
41
35
|
|
42
36
|
context 'empty?' do
|
@@ -54,6 +48,11 @@ module Bullet
|
|
54
48
|
response = double(body: '')
|
55
49
|
expect(middleware).to be_empty(response)
|
56
50
|
end
|
51
|
+
|
52
|
+
it 'should be true if no response body' do
|
53
|
+
response = double()
|
54
|
+
expect(middleware).to be_empty(response)
|
55
|
+
end
|
57
56
|
end
|
58
57
|
|
59
58
|
context '#call' do
|
@@ -90,7 +89,7 @@ module Bullet
|
|
90
89
|
before do
|
91
90
|
expect(Bullet).to receive(:notification?).and_return(true)
|
92
91
|
allow(Bullet).to receive(:gather_inline_notifications).and_return('<bullet></bullet>')
|
93
|
-
allow(middleware).to receive(:xhr_script).and_return('')
|
92
|
+
allow(middleware).to receive(:xhr_script).and_return('<script></script>')
|
94
93
|
allow(middleware).to receive(:footer_note).and_return('footer')
|
95
94
|
expect(Bullet).to receive(:perform_out_of_channel_notifications)
|
96
95
|
end
|
@@ -99,21 +98,28 @@ module Bullet
|
|
99
98
|
expect(Bullet).to receive(:add_footer).exactly(3).times.and_return(true)
|
100
99
|
_, headers, response = middleware.call('Content-Type' => 'text/html')
|
101
100
|
|
102
|
-
expect(headers['Content-Length']).to eq((
|
103
|
-
expect(response
|
104
|
-
expect(response.first).to include('<bullet></bullet><')
|
101
|
+
expect(headers['Content-Length']).to eq((73 + middleware.send(:footer_note).length).to_s)
|
102
|
+
expect(response).to eq(%w[<html><head></head><body>footer<bullet></bullet><script></script></body></html>])
|
105
103
|
end
|
106
104
|
|
107
105
|
it 'should change response body for html safe string if add_footer is true' do
|
108
106
|
expect(Bullet).to receive(:add_footer).exactly(3).times.and_return(true)
|
109
|
-
app.response =
|
110
|
-
|
111
|
-
|
107
|
+
app.response =
|
108
|
+
Support::ResponseDouble.new.tap do |response|
|
109
|
+
response.body = ActiveSupport::SafeBuffer.new('<html><head></head><body></body></html>')
|
110
|
+
end
|
112
111
|
_, headers, response = middleware.call('Content-Type' => 'text/html')
|
113
112
|
|
114
|
-
expect(headers['Content-Length']).to eq((
|
115
|
-
expect(response
|
116
|
-
|
113
|
+
expect(headers['Content-Length']).to eq((73 + middleware.send(:footer_note).length).to_s)
|
114
|
+
expect(response).to eq(%w[<html><head></head><body>footer<bullet></bullet><script></script></body></html>])
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should add the footer-text header for non-html requests when add_footer is true' do
|
118
|
+
allow(Bullet).to receive(:add_footer).at_least(:once).and_return(true)
|
119
|
+
allow(Bullet).to receive(:footer_info).and_return(['footer text'])
|
120
|
+
app.headers = { 'Content-Type' => 'application/json' }
|
121
|
+
_, headers, _response = middleware.call({})
|
122
|
+
expect(headers).to include('X-bullet-footer-text' => '["footer text"]')
|
117
123
|
end
|
118
124
|
|
119
125
|
it 'should change response body if console_enabled is true' do
|
@@ -125,20 +131,71 @@ module Bullet
|
|
125
131
|
|
126
132
|
it 'should change response body for html safe string if console_enabled is true' do
|
127
133
|
expect(Bullet).to receive(:console_enabled?).and_return(true)
|
128
|
-
app.response =
|
129
|
-
|
130
|
-
|
134
|
+
app.response =
|
135
|
+
Support::ResponseDouble.new.tap do |response|
|
136
|
+
response.body = ActiveSupport::SafeBuffer.new('<html><head></head><body></body></html>')
|
137
|
+
end
|
131
138
|
_, headers, response = middleware.call('Content-Type' => 'text/html')
|
132
139
|
expect(headers['Content-Length']).to eq('56')
|
133
140
|
expect(response).to eq(%w[<html><head></head><body><bullet></bullet></body></html>])
|
134
141
|
end
|
135
142
|
|
143
|
+
it 'should add headers for non-html requests when console_enabled is true' do
|
144
|
+
allow(Bullet).to receive(:console_enabled?).at_least(:once).and_return(true)
|
145
|
+
allow(Bullet).to receive(:text_notifications).and_return(['text notifications'])
|
146
|
+
app.headers = { 'Content-Type' => 'application/json' }
|
147
|
+
_, headers, _response = middleware.call({})
|
148
|
+
expect(headers).to include('X-bullet-console-text' => '["text notifications"]')
|
149
|
+
end
|
150
|
+
|
136
151
|
it "shouldn't change response body unnecessarily" do
|
137
152
|
expected_response = Support::ResponseDouble.new 'Actual body'
|
138
153
|
app.response = expected_response
|
139
154
|
_, _, response = middleware.call({})
|
140
155
|
expect(response).to eq(expected_response)
|
141
156
|
end
|
157
|
+
|
158
|
+
it "shouldn't add headers unnecessarily" do
|
159
|
+
app.headers = { 'Content-Type' => 'application/json' }
|
160
|
+
_, headers, _response = middleware.call({})
|
161
|
+
expect(headers).not_to include('X-bullet-footer-text')
|
162
|
+
expect(headers).not_to include('X-bullet-console-text')
|
163
|
+
end
|
164
|
+
|
165
|
+
context 'when skip_http_headers is enabled' do
|
166
|
+
before do
|
167
|
+
allow(Bullet).to receive(:skip_http_headers).and_return(true)
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'should include the footer but not the xhr script tag if add_footer is true' do
|
171
|
+
expect(Bullet).to receive(:add_footer).at_least(:once).and_return(true)
|
172
|
+
_, headers, response = middleware.call({})
|
173
|
+
|
174
|
+
expect(headers['Content-Length']).to eq((56 + middleware.send(:footer_note).length).to_s)
|
175
|
+
expect(response).to eq(%w[<html><head></head><body>footer<bullet></bullet></body></html>])
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'should not include the xhr script tag if console_enabled is true' do
|
179
|
+
expect(Bullet).to receive(:console_enabled?).and_return(true)
|
180
|
+
_, headers, response = middleware.call({})
|
181
|
+
expect(headers['Content-Length']).to eq('56')
|
182
|
+
expect(response).to eq(%w[<html><head></head><body><bullet></bullet></body></html>])
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should not add the footer-text header for non-html requests when add_footer is true' do
|
186
|
+
allow(Bullet).to receive(:add_footer).at_least(:once).and_return(true)
|
187
|
+
app.headers = { 'Content-Type' => 'application/json' }
|
188
|
+
_, headers, _response = middleware.call({})
|
189
|
+
expect(headers).not_to include('X-bullet-footer-text')
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'should not add headers for non-html requests when console_enabled is true' do
|
193
|
+
allow(Bullet).to receive(:console_enabled?).at_least(:once).and_return(true)
|
194
|
+
app.headers = { 'Content-Type' => 'application/json' }
|
195
|
+
_, headers, _response = middleware.call({})
|
196
|
+
expect(headers).not_to include('X-bullet-console-text')
|
197
|
+
end
|
198
|
+
end
|
142
199
|
end
|
143
200
|
|
144
201
|
context 'when skip_html_injection is enabled' do
|
@@ -203,6 +260,20 @@ module Bullet
|
|
203
260
|
expect(middleware.response_body(response)).to eq body_string
|
204
261
|
end
|
205
262
|
end
|
263
|
+
|
264
|
+
begin
|
265
|
+
require 'rack/files'
|
266
|
+
|
267
|
+
context 'when `response` is a Rack::Files::Iterator' do
|
268
|
+
let(:response) { instance_double(::Rack::Files::Iterator) }
|
269
|
+
before { allow(response).to receive(:is_a?).with(::Rack::Files::Iterator) { true } }
|
270
|
+
|
271
|
+
it 'should return nil' do
|
272
|
+
expect(middleware.response_body(response)).to be_nil
|
273
|
+
end
|
274
|
+
end
|
275
|
+
rescue LoadError
|
276
|
+
end
|
206
277
|
end
|
207
278
|
end
|
208
279
|
end
|
data/spec/bullet_spec.rb
CHANGED
@@ -74,31 +74,31 @@ describe Bullet, focused: true do
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
describe '#
|
77
|
+
describe '#add_safelist' do
|
78
78
|
context "for 'special' class names" do
|
79
|
-
it 'is added to the
|
80
|
-
Bullet.
|
81
|
-
expect(Bullet.
|
79
|
+
it 'is added to the safelist successfully' do
|
80
|
+
Bullet.add_safelist(type: :n_plus_one_query, class_name: 'Klass', association: :department)
|
81
|
+
expect(Bullet.get_safelist_associations(:n_plus_one_query, 'Klass')).to include :department
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
describe '#
|
86
|
+
describe '#delete_safelist' do
|
87
87
|
context "for 'special' class names" do
|
88
|
-
it 'is deleted from the
|
89
|
-
Bullet.
|
90
|
-
Bullet.
|
91
|
-
expect(Bullet.
|
88
|
+
it 'is deleted from the safelist successfully' do
|
89
|
+
Bullet.add_safelist(type: :n_plus_one_query, class_name: 'Klass', association: :department)
|
90
|
+
Bullet.delete_safelist(type: :n_plus_one_query, class_name: 'Klass', association: :department)
|
91
|
+
expect(Bullet.safelist[:n_plus_one_query]).to eq({})
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
95
|
context 'when exists multiple definitions' do
|
96
|
-
it 'is deleted from the
|
97
|
-
Bullet.
|
98
|
-
Bullet.
|
99
|
-
Bullet.
|
100
|
-
expect(Bullet.
|
101
|
-
expect(Bullet.
|
96
|
+
it 'is deleted from the safelist successfully' do
|
97
|
+
Bullet.add_safelist(type: :n_plus_one_query, class_name: 'Klass', association: :department)
|
98
|
+
Bullet.add_safelist(type: :n_plus_one_query, class_name: 'Klass', association: :team)
|
99
|
+
Bullet.delete_safelist(type: :n_plus_one_query, class_name: 'Klass', association: :team)
|
100
|
+
expect(Bullet.get_safelist_associations(:n_plus_one_query, 'Klass')).to include :department
|
101
|
+
expect(Bullet.get_safelist_associations(:n_plus_one_query, 'Klass')).to_not include :team
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
@@ -129,7 +129,7 @@ if active_record?
|
|
129
129
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
130
130
|
end
|
131
131
|
|
132
|
-
it 'should detect unused preload with post =>
|
132
|
+
it 'should detect unused preload with post => comments, no category => posts' do
|
133
133
|
Category.includes(posts: :comments).each { |category| category.posts.map(&:name) }
|
134
134
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
135
135
|
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Post, :comments)
|
@@ -202,7 +202,7 @@ if active_record?
|
|
202
202
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
203
203
|
end
|
204
204
|
|
205
|
-
it 'should detect preload with post =>
|
205
|
+
it 'should detect preload with post => comments' do
|
206
206
|
Post.first.comments.map(&:name)
|
207
207
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
208
208
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
@@ -401,6 +401,15 @@ if active_record?
|
|
401
401
|
end
|
402
402
|
|
403
403
|
describe Bullet::Detector::Association, 'has_and_belongs_to_many' do
|
404
|
+
context 'posts <=> deals' do
|
405
|
+
it 'should detect preload associations with join tables that have identifier' do
|
406
|
+
Post.includes(:deals).each { |post| post.deals.map(&:name) }
|
407
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
408
|
+
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
409
|
+
|
410
|
+
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
411
|
+
end
|
412
|
+
end
|
404
413
|
context 'students <=> teachers' do
|
405
414
|
it 'should detect non preload associations' do
|
406
415
|
Student.all.each { |student| student.teachers.map(&:name) }
|
@@ -442,6 +451,16 @@ if active_record?
|
|
442
451
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Student, :teachers)
|
443
452
|
end
|
444
453
|
end
|
454
|
+
|
455
|
+
context 'user => roles' do
|
456
|
+
it 'should detect preload associations' do
|
457
|
+
User.first.roles.includes(:resource).each { |role| role.resource }
|
458
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
459
|
+
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
460
|
+
|
461
|
+
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
462
|
+
end
|
463
|
+
end
|
445
464
|
end
|
446
465
|
|
447
466
|
describe Bullet::Detector::Association, 'has_many :through' do
|
@@ -729,9 +748,9 @@ if active_record?
|
|
729
748
|
end
|
730
749
|
end
|
731
750
|
|
732
|
-
context '
|
733
|
-
before { Bullet.
|
734
|
-
after { Bullet.
|
751
|
+
context 'add n plus one query to safelist' do
|
752
|
+
before { Bullet.add_safelist type: :n_plus_one_query, class_name: 'Post', association: :comments }
|
753
|
+
after { Bullet.clear_safelist }
|
735
754
|
|
736
755
|
it 'should not detect n plus one query' do
|
737
756
|
Post.all.each { |post| post.comments.map(&:name) }
|
@@ -750,9 +769,9 @@ if active_record?
|
|
750
769
|
end
|
751
770
|
end
|
752
771
|
|
753
|
-
context '
|
754
|
-
before { Bullet.
|
755
|
-
after { Bullet.
|
772
|
+
context 'add unused eager loading to safelist' do
|
773
|
+
before { Bullet.add_safelist type: :unused_eager_loading, class_name: 'Post', association: :comments }
|
774
|
+
after { Bullet.clear_safelist }
|
756
775
|
|
757
776
|
it 'should not detect unused eager loading' do
|
758
777
|
Post.includes(:comments).map(&:name)
|
@@ -28,7 +28,7 @@ if !mongoid? && active_record?
|
|
28
28
|
expect(Bullet.collected_counter_cache_notifications).to be_empty
|
29
29
|
end
|
30
30
|
|
31
|
-
if
|
31
|
+
if ActiveRecord::VERSION::MAJOR > 4
|
32
32
|
it 'should not need counter cache for has_many through' do
|
33
33
|
Client.all.each { |client| client.firms.size }
|
34
34
|
expect(Bullet.collected_counter_cache_notifications).to be_empty
|
@@ -55,9 +55,9 @@ if !mongoid? && active_record?
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
context '
|
59
|
-
before { Bullet.
|
60
|
-
after { Bullet.
|
58
|
+
context 'safelist' do
|
59
|
+
before { Bullet.add_safelist type: :counter_cache, class_name: 'Country', association: :cities }
|
60
|
+
after { Bullet.clear_safelist }
|
61
61
|
|
62
62
|
it 'should not detect counter cache' do
|
63
63
|
Country.all.each { |country| country.cities.size }
|
@@ -118,7 +118,7 @@ if mongoid?
|
|
118
118
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
119
119
|
end
|
120
120
|
|
121
|
-
it 'should detect preload with post =>
|
121
|
+
it 'should detect preload with post => comments' do
|
122
122
|
Mongoid::Post.first.comments.map(&:name)
|
123
123
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
124
124
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
data/spec/models/deal.rb
ADDED
data/spec/models/folder.rb
CHANGED
data/spec/models/group.rb
CHANGED
data/spec/models/page.rb
CHANGED
data/spec/models/post.rb
CHANGED
@@ -4,6 +4,7 @@ class Post < ActiveRecord::Base
|
|
4
4
|
belongs_to :category, inverse_of: :posts
|
5
5
|
belongs_to :writer
|
6
6
|
has_many :comments, inverse_of: :post
|
7
|
+
has_and_belongs_to_many :deals
|
7
8
|
|
8
9
|
validates :category, presence: true
|
9
10
|
|
@@ -21,6 +22,7 @@ class Post < ActiveRecord::Base
|
|
21
22
|
next unless trigger_after_save
|
22
23
|
|
23
24
|
temp_comment = Comment.new(post: self)
|
25
|
+
|
24
26
|
# this triggers self to be "possible", even though it's
|
25
27
|
# not saved yet
|
26
28
|
temp_comment.post
|
data/spec/models/role.rb
ADDED
data/spec/models/user.rb
CHANGED
data/spec/models/writer.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/support/mongo_seed.rb
CHANGED
@@ -45,6 +45,7 @@ module Support
|
|
45
45
|
Mongoid.configure do |config|
|
46
46
|
config.load_configuration(clients: { default: { database: 'bullet', hosts: %w[localhost:27017] } })
|
47
47
|
end
|
48
|
+
|
48
49
|
# Increase the level from DEBUG in order to avoid excessive logging to the screen
|
49
50
|
Mongo::Logger.logger.level = Logger::WARN
|
50
51
|
end
|
data/spec/support/sqlite_seed.rb
CHANGED
@@ -21,6 +21,13 @@ module Support
|
|
21
21
|
post2 = category2.posts.create(name: 'second', writer: writer2)
|
22
22
|
post3 = category2.posts.create(name: 'third', writer: writer2)
|
23
23
|
|
24
|
+
deal1 = Deal.new(name: 'Deal 1')
|
25
|
+
deal1.posts << post1
|
26
|
+
deal1.posts << post2
|
27
|
+
deal2 = Deal.new(name: 'Deal 2')
|
28
|
+
post1.deals << deal1
|
29
|
+
post1.deals << deal2
|
30
|
+
|
24
31
|
comment1 = post1.comments.create(name: 'first', author: writer1)
|
25
32
|
comment2 = post1.comments.create(name: 'first2', author: writer1)
|
26
33
|
comment3 = post1.comments.create(name: 'first3', author: writer1)
|
@@ -85,9 +92,16 @@ module Support
|
|
85
92
|
page3 = Page.create(name: 'page3', parent_id: folder2.id, author_id: author2.id)
|
86
93
|
page4 = Page.create(name: 'page4', parent_id: folder2.id, author_id: author2.id)
|
87
94
|
|
95
|
+
role1 = Role.create(name: 'Amdin')
|
96
|
+
role2 = Role.create(name: 'User')
|
97
|
+
|
88
98
|
user1 = User.create(name: 'user1', category: category1)
|
89
99
|
user2 = User.create(name: 'user2', category: category1)
|
90
100
|
|
101
|
+
user1.roles << role1
|
102
|
+
user1.roles << role2
|
103
|
+
user2.roles << role2
|
104
|
+
|
91
105
|
submission1 = user1.create_submission(name: 'submission1')
|
92
106
|
submission2 = user2.create_submission(name: 'submission2')
|
93
107
|
|
@@ -156,6 +170,11 @@ module Support
|
|
156
170
|
t.column :hotel_id, :integer
|
157
171
|
end
|
158
172
|
|
173
|
+
create_table :deals_posts do |t|
|
174
|
+
t.column :deal_id, :integer
|
175
|
+
t.column :post_id, :integer
|
176
|
+
end
|
177
|
+
|
159
178
|
create_table :documents do |t|
|
160
179
|
t.string :name
|
161
180
|
t.string :type
|
@@ -234,6 +253,17 @@ module Support
|
|
234
253
|
t.column :submission_id, :integer
|
235
254
|
end
|
236
255
|
|
256
|
+
create_table :roles do |t|
|
257
|
+
t.column :name, :string
|
258
|
+
t.column :resource_id, :integer
|
259
|
+
t.column :resource_type, :string
|
260
|
+
end
|
261
|
+
|
262
|
+
create_table :roles_users do |t|
|
263
|
+
t.column :role_id, :integer
|
264
|
+
t.column :user_id, :integer
|
265
|
+
end
|
266
|
+
|
237
267
|
create_table :submissions do |t|
|
238
268
|
t.column :name, :string
|
239
269
|
t.column :user_id, :integer
|
data/test.sh
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
#bundle update rails && bundle exec rspec spec
|
2
2
|
#BUNDLE_GEMFILE=Gemfile.mongoid bundle update mongoid && BUNDLE_GEMFILE=Gemfile.mongoid bundle exec rspec spec
|
3
|
+
BUNDLE_GEMFILE=Gemfile.rails-7.0 bundle && BUNDLE_GEMFILE=Gemfile.rails-7.0 bundle exec rspec spec
|
4
|
+
BUNDLE_GEMFILE=Gemfile.rails-6.1 bundle && BUNDLE_GEMFILE=Gemfile.rails-6.1 bundle exec rspec spec
|
3
5
|
BUNDLE_GEMFILE=Gemfile.rails-6.0 bundle && BUNDLE_GEMFILE=Gemfile.rails-6.0 bundle exec rspec spec
|
4
6
|
BUNDLE_GEMFILE=Gemfile.rails-5.2 bundle && BUNDLE_GEMFILE=Gemfile.rails-5.2 bundle exec rspec spec
|
5
7
|
BUNDLE_GEMFILE=Gemfile.rails-5.1 bundle && BUNDLE_GEMFILE=Gemfile.rails-5.1 bundle exec rspec spec
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -45,9 +45,9 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- ".github/workflows/main.yml"
|
48
49
|
- ".gitignore"
|
49
50
|
- ".rspec"
|
50
|
-
- ".travis.yml"
|
51
51
|
- CHANGELOG.md
|
52
52
|
- Gemfile
|
53
53
|
- Gemfile.mongoid
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- Gemfile.rails-5.2
|
64
64
|
- Gemfile.rails-6.0
|
65
65
|
- Gemfile.rails-6.1
|
66
|
+
- Gemfile.rails-7.0
|
66
67
|
- Guardfile
|
67
68
|
- Hacking.md
|
68
69
|
- MIT-LICENSE
|
@@ -78,6 +79,7 @@ files:
|
|
78
79
|
- lib/bullet/active_record52.rb
|
79
80
|
- lib/bullet/active_record60.rb
|
80
81
|
- lib/bullet/active_record61.rb
|
82
|
+
- lib/bullet/active_record70.rb
|
81
83
|
- lib/bullet/bullet_xhr.js
|
82
84
|
- lib/bullet/dependency.rb
|
83
85
|
- lib/bullet/detector.rb
|
@@ -138,6 +140,7 @@ files:
|
|
138
140
|
- spec/models/comment.rb
|
139
141
|
- spec/models/company.rb
|
140
142
|
- spec/models/country.rb
|
143
|
+
- spec/models/deal.rb
|
141
144
|
- spec/models/document.rb
|
142
145
|
- spec/models/entry.rb
|
143
146
|
- spec/models/firm.rb
|
@@ -157,6 +160,7 @@ files:
|
|
157
160
|
- spec/models/post.rb
|
158
161
|
- spec/models/relationship.rb
|
159
162
|
- spec/models/reply.rb
|
163
|
+
- spec/models/role.rb
|
160
164
|
- spec/models/student.rb
|
161
165
|
- spec/models/submission.rb
|
162
166
|
- spec/models/teacher.rb
|
@@ -191,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
195
|
- !ruby/object:Gem::Version
|
192
196
|
version: 1.3.6
|
193
197
|
requirements: []
|
194
|
-
rubygems_version: 3.
|
198
|
+
rubygems_version: 3.3.7
|
195
199
|
signing_key:
|
196
200
|
specification_version: 4
|
197
201
|
summary: help to kill N+1 queries and unused eager loading.
|
@@ -226,6 +230,7 @@ test_files:
|
|
226
230
|
- spec/models/comment.rb
|
227
231
|
- spec/models/company.rb
|
228
232
|
- spec/models/country.rb
|
233
|
+
- spec/models/deal.rb
|
229
234
|
- spec/models/document.rb
|
230
235
|
- spec/models/entry.rb
|
231
236
|
- spec/models/firm.rb
|
@@ -245,6 +250,7 @@ test_files:
|
|
245
250
|
- spec/models/post.rb
|
246
251
|
- spec/models/relationship.rb
|
247
252
|
- spec/models/reply.rb
|
253
|
+
- spec/models/role.rb
|
248
254
|
- spec/models/student.rb
|
249
255
|
- spec/models/submission.rb
|
250
256
|
- spec/models/teacher.rb
|
data/.travis.yml
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.3.0
|
4
|
-
- 2.6.0
|
5
|
-
gemfile:
|
6
|
-
- Gemfile.rails-6.0
|
7
|
-
- Gemfile.rails-5.2
|
8
|
-
- Gemfile.rails-5.1
|
9
|
-
- Gemfile.rails-5.0
|
10
|
-
- Gemfile.rails-4.2
|
11
|
-
- Gemfile.rails-4.1
|
12
|
-
- Gemfile.rails-4.0
|
13
|
-
matrix:
|
14
|
-
exclude:
|
15
|
-
- rvm: 2.3.0
|
16
|
-
gemfile: Gemfile.rails-6.0
|
17
|
-
- rvm: 2.6.0
|
18
|
-
gemfile: Gemfile.rails-5.2
|
19
|
-
- rvm: 2.6.0
|
20
|
-
gemfile: Gemfile.rails-5.1
|
21
|
-
- rvm: 2.6.0
|
22
|
-
gemfile: Gemfile.rails-5.0
|
23
|
-
- rvm: 2.6.0
|
24
|
-
gemfile: Gemfile.rails-4.2
|
25
|
-
- rvm: 2.6.0
|
26
|
-
gemfile: Gemfile.rails-4.1
|
27
|
-
- rvm: 2.6.0
|
28
|
-
gemfile: Gemfile.rails-4.0
|
29
|
-
env:
|
30
|
-
- DB=sqlite
|
31
|
-
before_install:
|
32
|
-
- "find /home/travis/.rvm/rubies -wholename '*default/bundler-*.gemspec' -delete"
|
33
|
-
- gem install bundler -v '< 2'
|