bullet 7.0.7 → 7.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -2
  3. data/README.md +7 -3
  4. data/lib/bullet/active_record4.rb +21 -6
  5. data/lib/bullet/active_record41.rb +21 -6
  6. data/lib/bullet/active_record42.rb +32 -12
  7. data/lib/bullet/active_record5.rb +40 -12
  8. data/lib/bullet/active_record52.rb +40 -12
  9. data/lib/bullet/active_record60.rb +40 -12
  10. data/lib/bullet/active_record61.rb +40 -12
  11. data/lib/bullet/active_record70.rb +54 -20
  12. data/lib/bullet/active_record71.rb +318 -0
  13. data/lib/bullet/dependency.rb +12 -0
  14. data/lib/bullet/detector/n_plus_one_query.rb +2 -5
  15. data/lib/bullet/detector/unused_eager_loading.rb +5 -2
  16. data/lib/bullet/ext/object.rb +14 -3
  17. data/lib/bullet/mongoid8x.rb +59 -0
  18. data/lib/bullet/notification/base.rb +22 -10
  19. data/lib/bullet/notification/counter_cache.rb +1 -1
  20. data/lib/bullet/rack.rb +4 -2
  21. data/lib/bullet/registry/association.rb +2 -1
  22. data/lib/bullet/stack_trace_filter.rb +3 -2
  23. data/lib/bullet/version.rb +1 -1
  24. data/lib/bullet.rb +11 -2
  25. metadata +7 -155
  26. data/.github/workflows/main.yml +0 -82
  27. data/.gitignore +0 -15
  28. data/.rspec +0 -2
  29. data/Gemfile +0 -24
  30. data/Gemfile.mongoid +0 -12
  31. data/Gemfile.mongoid-4.0 +0 -15
  32. data/Gemfile.mongoid-5.0 +0 -15
  33. data/Gemfile.mongoid-6.0 +0 -15
  34. data/Gemfile.mongoid-7.0 +0 -15
  35. data/Gemfile.rails-4.0 +0 -16
  36. data/Gemfile.rails-4.1 +0 -16
  37. data/Gemfile.rails-4.2 +0 -16
  38. data/Gemfile.rails-5.0 +0 -15
  39. data/Gemfile.rails-5.1 +0 -15
  40. data/Gemfile.rails-5.2 +0 -15
  41. data/Gemfile.rails-6.0 +0 -15
  42. data/Gemfile.rails-6.1 +0 -15
  43. data/Gemfile.rails-7.0 +0 -10
  44. data/Guardfile +0 -8
  45. data/Hacking.md +0 -75
  46. data/Rakefile +0 -51
  47. data/bullet.gemspec +0 -33
  48. data/perf/benchmark.rb +0 -118
  49. data/rails/init.rb +0 -3
  50. data/spec/bullet/detector/association_spec.rb +0 -28
  51. data/spec/bullet/detector/base_spec.rb +0 -10
  52. data/spec/bullet/detector/counter_cache_spec.rb +0 -58
  53. data/spec/bullet/detector/n_plus_one_query_spec.rb +0 -150
  54. data/spec/bullet/detector/unused_eager_loading_spec.rb +0 -126
  55. data/spec/bullet/ext/object_spec.rb +0 -44
  56. data/spec/bullet/ext/string_spec.rb +0 -15
  57. data/spec/bullet/notification/base_spec.rb +0 -94
  58. data/spec/bullet/notification/counter_cache_spec.rb +0 -14
  59. data/spec/bullet/notification/n_plus_one_query_spec.rb +0 -29
  60. data/spec/bullet/notification/unused_eager_loading_spec.rb +0 -18
  61. data/spec/bullet/notification_collector_spec.rb +0 -34
  62. data/spec/bullet/rack_spec.rb +0 -296
  63. data/spec/bullet/registry/association_spec.rb +0 -28
  64. data/spec/bullet/registry/base_spec.rb +0 -46
  65. data/spec/bullet/registry/object_spec.rb +0 -26
  66. data/spec/bullet/stack_trace_filter_spec.rb +0 -26
  67. data/spec/bullet_spec.rb +0 -136
  68. data/spec/integration/active_record/association_spec.rb +0 -822
  69. data/spec/integration/counter_cache_spec.rb +0 -68
  70. data/spec/integration/mongoid/association_spec.rb +0 -246
  71. data/spec/models/address.rb +0 -5
  72. data/spec/models/attachment.rb +0 -5
  73. data/spec/models/author.rb +0 -5
  74. data/spec/models/base_user.rb +0 -7
  75. data/spec/models/category.rb +0 -12
  76. data/spec/models/city.rb +0 -5
  77. data/spec/models/client.rb +0 -8
  78. data/spec/models/comment.rb +0 -8
  79. data/spec/models/company.rb +0 -5
  80. data/spec/models/country.rb +0 -5
  81. data/spec/models/deal.rb +0 -5
  82. data/spec/models/document.rb +0 -7
  83. data/spec/models/entry.rb +0 -5
  84. data/spec/models/firm.rb +0 -7
  85. data/spec/models/folder.rb +0 -4
  86. data/spec/models/group.rb +0 -4
  87. data/spec/models/mongoid/address.rb +0 -9
  88. data/spec/models/mongoid/category.rb +0 -10
  89. data/spec/models/mongoid/comment.rb +0 -9
  90. data/spec/models/mongoid/company.rb +0 -9
  91. data/spec/models/mongoid/entry.rb +0 -9
  92. data/spec/models/mongoid/post.rb +0 -14
  93. data/spec/models/mongoid/user.rb +0 -7
  94. data/spec/models/newspaper.rb +0 -5
  95. data/spec/models/page.rb +0 -4
  96. data/spec/models/person.rb +0 -5
  97. data/spec/models/pet.rb +0 -5
  98. data/spec/models/post.rb +0 -34
  99. data/spec/models/relationship.rb +0 -6
  100. data/spec/models/reply.rb +0 -5
  101. data/spec/models/role.rb +0 -7
  102. data/spec/models/student.rb +0 -5
  103. data/spec/models/submission.rb +0 -7
  104. data/spec/models/teacher.rb +0 -5
  105. data/spec/models/user.rb +0 -8
  106. data/spec/models/writer.rb +0 -4
  107. data/spec/spec_helper.rb +0 -97
  108. data/spec/support/bullet_ext.rb +0 -56
  109. data/spec/support/mongo_seed.rb +0 -59
  110. data/spec/support/rack_double.rb +0 -49
  111. data/spec/support/sqlite_seed.rb +0 -284
  112. data/test.sh +0 -15
  113. data/update.sh +0 -10
data/spec/bullet_spec.rb DELETED
@@ -1,136 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Bullet, focused: true do
6
- subject { Bullet }
7
-
8
- describe '#enable' do
9
- context 'enable Bullet' do
10
- before do
11
- # Bullet.enable
12
- # Do nothing. Bullet has already been enabled for the whole test suite.
13
- end
14
-
15
- it 'should be enabled' do
16
- expect(subject).to be_enable
17
- end
18
-
19
- context 'disable Bullet' do
20
- before { Bullet.enable = false }
21
-
22
- it 'should be disabled' do
23
- expect(subject).to_not be_enable
24
- end
25
-
26
- context 'enable Bullet again without patching again the orms' do
27
- before do
28
- expect(Bullet::Mongoid).not_to receive(:enable) if defined?(Bullet::Mongoid)
29
- expect(Bullet::ActiveRecord).not_to receive(:enable) if defined?(Bullet::ActiveRecord)
30
- Bullet.enable = true
31
- end
32
-
33
- it 'should be enabled again' do
34
- expect(subject).to be_enable
35
- end
36
- end
37
- end
38
- end
39
- end
40
-
41
- describe '#start?' do
42
- context 'when bullet is disabled' do
43
- before(:each) { Bullet.enable = false }
44
-
45
- it 'should not be started' do
46
- expect(Bullet).not_to be_start
47
- end
48
- end
49
- end
50
-
51
- describe '#debug' do
52
- before(:each) { $stdout = StringIO.new }
53
-
54
- after(:each) { $stdout = STDOUT }
55
-
56
- context 'when debug is enabled' do
57
- before(:each) { ENV['BULLET_DEBUG'] = 'true' }
58
-
59
- after(:each) { ENV['BULLET_DEBUG'] = 'false' }
60
-
61
- it 'should output debug information' do
62
- Bullet.debug('debug_message', 'this is helpful information')
63
-
64
- expect($stdout.string).to eq("[Bullet][debug_message] this is helpful information\n")
65
- end
66
- end
67
-
68
- context 'when debug is disabled' do
69
- it 'should output debug information' do
70
- Bullet.debug('debug_message', 'this is helpful information')
71
-
72
- expect($stdout.string).to be_empty
73
- end
74
- end
75
- end
76
-
77
- describe '#add_safelist' do
78
- context "for 'special' class names" do
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
- end
83
- end
84
- end
85
-
86
- describe '#delete_safelist' do
87
- context "for 'special' class names" do
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
- end
93
- end
94
-
95
- context 'when exists multiple definitions' do
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
- end
103
- end
104
- end
105
-
106
- describe '#perform_out_of_channel_notifications' do
107
- let(:notification) { double }
108
-
109
- before do
110
- allow(Bullet).to receive(:for_each_active_notifier_with_notification).and_yield(notification)
111
- allow(notification).to receive(:notify_out_of_channel)
112
- end
113
-
114
- context 'when called with Rack environment hash' do
115
- let(:env) { { 'REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/path', 'QUERY_STRING' => 'foo=bar' } }
116
-
117
- context "when env['REQUEST_URI'] is nil" do
118
- before { env['REQUEST_URI'] = nil }
119
-
120
- it 'should notification.url is built' do
121
- expect(notification).to receive(:url=).with('GET /path?foo=bar')
122
- Bullet.perform_out_of_channel_notifications(env)
123
- end
124
- end
125
-
126
- context "when env['REQUEST_URI'] is present" do
127
- before { env['REQUEST_URI'] = 'http://example.com/path' }
128
-
129
- it "should notification.url is env['REQUEST_URI']" do
130
- expect(notification).to receive(:url=).with('GET http://example.com/path')
131
- Bullet.perform_out_of_channel_notifications(env)
132
- end
133
- end
134
- end
135
- end
136
- end