bullet 7.0.6 → 7.1.0

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.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -1
  3. data/README.md +3 -0
  4. data/lib/bullet/active_record4.rb +9 -0
  5. data/lib/bullet/active_record41.rb +9 -0
  6. data/lib/bullet/active_record42.rb +9 -0
  7. data/lib/bullet/active_record5.rb +11 -0
  8. data/lib/bullet/active_record52.rb +11 -0
  9. data/lib/bullet/active_record60.rb +11 -0
  10. data/lib/bullet/active_record61.rb +11 -0
  11. data/lib/bullet/active_record70.rb +19 -6
  12. data/lib/bullet/active_record71.rb +297 -0
  13. data/lib/bullet/dependency.rb +12 -0
  14. data/lib/bullet/detector/unused_eager_loading.rb +1 -1
  15. data/lib/bullet/mongoid8x.rb +59 -0
  16. data/lib/bullet/notification/counter_cache.rb +1 -1
  17. data/lib/bullet/rack.rb +1 -1
  18. data/lib/bullet/version.rb +1 -1
  19. data/lib/bullet.rb +6 -2
  20. metadata +7 -155
  21. data/.github/workflows/main.yml +0 -82
  22. data/.gitignore +0 -15
  23. data/.rspec +0 -2
  24. data/Gemfile +0 -24
  25. data/Gemfile.mongoid +0 -12
  26. data/Gemfile.mongoid-4.0 +0 -15
  27. data/Gemfile.mongoid-5.0 +0 -15
  28. data/Gemfile.mongoid-6.0 +0 -15
  29. data/Gemfile.mongoid-7.0 +0 -15
  30. data/Gemfile.rails-4.0 +0 -16
  31. data/Gemfile.rails-4.1 +0 -16
  32. data/Gemfile.rails-4.2 +0 -16
  33. data/Gemfile.rails-5.0 +0 -15
  34. data/Gemfile.rails-5.1 +0 -15
  35. data/Gemfile.rails-5.2 +0 -15
  36. data/Gemfile.rails-6.0 +0 -15
  37. data/Gemfile.rails-6.1 +0 -15
  38. data/Gemfile.rails-7.0 +0 -10
  39. data/Guardfile +0 -8
  40. data/Hacking.md +0 -75
  41. data/Rakefile +0 -51
  42. data/bullet.gemspec +0 -33
  43. data/perf/benchmark.rb +0 -118
  44. data/rails/init.rb +0 -3
  45. data/spec/bullet/detector/association_spec.rb +0 -28
  46. data/spec/bullet/detector/base_spec.rb +0 -10
  47. data/spec/bullet/detector/counter_cache_spec.rb +0 -58
  48. data/spec/bullet/detector/n_plus_one_query_spec.rb +0 -150
  49. data/spec/bullet/detector/unused_eager_loading_spec.rb +0 -126
  50. data/spec/bullet/ext/object_spec.rb +0 -44
  51. data/spec/bullet/ext/string_spec.rb +0 -15
  52. data/spec/bullet/notification/base_spec.rb +0 -94
  53. data/spec/bullet/notification/counter_cache_spec.rb +0 -14
  54. data/spec/bullet/notification/n_plus_one_query_spec.rb +0 -29
  55. data/spec/bullet/notification/unused_eager_loading_spec.rb +0 -18
  56. data/spec/bullet/notification_collector_spec.rb +0 -34
  57. data/spec/bullet/rack_spec.rb +0 -296
  58. data/spec/bullet/registry/association_spec.rb +0 -28
  59. data/spec/bullet/registry/base_spec.rb +0 -46
  60. data/spec/bullet/registry/object_spec.rb +0 -26
  61. data/spec/bullet/stack_trace_filter_spec.rb +0 -26
  62. data/spec/bullet_spec.rb +0 -136
  63. data/spec/integration/active_record/association_spec.rb +0 -822
  64. data/spec/integration/counter_cache_spec.rb +0 -68
  65. data/spec/integration/mongoid/association_spec.rb +0 -246
  66. data/spec/models/address.rb +0 -5
  67. data/spec/models/attachment.rb +0 -5
  68. data/spec/models/author.rb +0 -5
  69. data/spec/models/base_user.rb +0 -7
  70. data/spec/models/category.rb +0 -12
  71. data/spec/models/city.rb +0 -5
  72. data/spec/models/client.rb +0 -8
  73. data/spec/models/comment.rb +0 -8
  74. data/spec/models/company.rb +0 -5
  75. data/spec/models/country.rb +0 -5
  76. data/spec/models/deal.rb +0 -5
  77. data/spec/models/document.rb +0 -7
  78. data/spec/models/entry.rb +0 -5
  79. data/spec/models/firm.rb +0 -7
  80. data/spec/models/folder.rb +0 -4
  81. data/spec/models/group.rb +0 -4
  82. data/spec/models/mongoid/address.rb +0 -9
  83. data/spec/models/mongoid/category.rb +0 -10
  84. data/spec/models/mongoid/comment.rb +0 -9
  85. data/spec/models/mongoid/company.rb +0 -9
  86. data/spec/models/mongoid/entry.rb +0 -9
  87. data/spec/models/mongoid/post.rb +0 -14
  88. data/spec/models/mongoid/user.rb +0 -7
  89. data/spec/models/newspaper.rb +0 -5
  90. data/spec/models/page.rb +0 -4
  91. data/spec/models/person.rb +0 -5
  92. data/spec/models/pet.rb +0 -5
  93. data/spec/models/post.rb +0 -34
  94. data/spec/models/relationship.rb +0 -6
  95. data/spec/models/reply.rb +0 -5
  96. data/spec/models/role.rb +0 -7
  97. data/spec/models/student.rb +0 -5
  98. data/spec/models/submission.rb +0 -7
  99. data/spec/models/teacher.rb +0 -5
  100. data/spec/models/user.rb +0 -8
  101. data/spec/models/writer.rb +0 -4
  102. data/spec/spec_helper.rb +0 -97
  103. data/spec/support/bullet_ext.rb +0 -56
  104. data/spec/support/mongo_seed.rb +0 -59
  105. data/spec/support/rack_double.rb +0 -49
  106. data/spec/support/sqlite_seed.rb +0 -284
  107. data/test.sh +0 -15
  108. 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