bullet 7.0.6 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- if !mongoid? && active_record?
6
- describe Bullet::Detector::CounterCache do
7
- before(:each) { Bullet.start_request }
8
-
9
- after(:each) { Bullet.end_request }
10
-
11
- it 'should need counter cache with all cities' do
12
- Country.all.each { |country| country.cities.size }
13
- expect(Bullet.collected_counter_cache_notifications).not_to be_empty
14
- end
15
-
16
- it 'should not need counter cache if already define counter_cache' do
17
- Person.all.each { |person| person.pets.size }
18
- expect(Bullet.collected_counter_cache_notifications).to be_empty
19
- end
20
-
21
- it 'should not need counter cache with only one object' do
22
- Country.first.cities.size
23
- expect(Bullet.collected_counter_cache_notifications).to be_empty
24
- end
25
-
26
- it 'should not need counter cache without size' do
27
- Country.includes(:cities).each { |country| country.cities.empty? }
28
- expect(Bullet.collected_counter_cache_notifications).to be_empty
29
- end
30
-
31
- if ActiveRecord::VERSION::MAJOR > 4
32
- it 'should not need counter cache for has_many through' do
33
- Client.all.each { |client| client.firms.size }
34
- expect(Bullet.collected_counter_cache_notifications).to be_empty
35
- end
36
- else
37
- it 'should need counter cache for has_many through' do
38
- Client.all.each { |client| client.firms.size }
39
- expect(Bullet.collected_counter_cache_notifications).not_to be_empty
40
- end
41
- end
42
-
43
- it 'should not need counter cache with part of cities' do
44
- Country.all.each { |country| country.cities.where(name: 'first').size }
45
- expect(Bullet.collected_counter_cache_notifications).to be_empty
46
- end
47
-
48
- context 'disable' do
49
- before { Bullet.counter_cache_enable = false }
50
- after { Bullet.counter_cache_enable = true }
51
-
52
- it 'should not detect counter cache' do
53
- Country.all.each { |country| country.cities.size }
54
- expect(Bullet.collected_counter_cache_notifications).to be_empty
55
- end
56
- end
57
-
58
- context 'safelist' do
59
- before { Bullet.add_safelist type: :counter_cache, class_name: 'Country', association: :cities }
60
- after { Bullet.clear_safelist }
61
-
62
- it 'should not detect counter cache' do
63
- Country.all.each { |country| country.cities.size }
64
- expect(Bullet.collected_counter_cache_notifications).to be_empty
65
- end
66
- end
67
- end
68
- end
@@ -1,246 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- if mongoid?
6
- describe Bullet::Detector::Association do
7
- context 'embeds_many' do
8
- context 'posts => users' do
9
- it 'should detect nothing' do
10
- Mongoid::Post.all.each { |post| post.users.map(&:name) }
11
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
12
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
13
-
14
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
15
- end
16
- end
17
- end
18
-
19
- context 'has_many' do
20
- context 'posts => comments' do
21
- it 'should detect non preload posts => comments' do
22
- Mongoid::Post.all.each { |post| post.comments.map(&:name) }
23
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
24
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
25
-
26
- expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Mongoid::Post, :comments)
27
- end
28
-
29
- it 'should detect preload post => comments' do
30
- Mongoid::Post.includes(:comments).each { |post| post.comments.map(&:name) }
31
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
32
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
33
-
34
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
35
- end
36
-
37
- it 'should detect unused preload post => comments' do
38
- Mongoid::Post.includes(:comments).map(&:name)
39
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
40
- expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Mongoid::Post, :comments)
41
-
42
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
43
- end
44
-
45
- it 'should not detect unused preload post => comments' do
46
- Mongoid::Post.all.map(&:name)
47
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
48
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
49
-
50
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
51
- end
52
- end
53
-
54
- context 'category => posts, category => entries' do
55
- it 'should detect non preload with category => [posts, entries]' do
56
- Mongoid::Category.all.each do |category|
57
- category.posts.map(&:name)
58
- category.entries.map(&:name)
59
- end
60
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
61
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
62
-
63
- expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Mongoid::Category, :posts)
64
- expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Mongoid::Category, :entries)
65
- end
66
-
67
- it 'should detect preload with category => posts, but not with category => entries' do
68
- Mongoid::Category.includes(:posts).each do |category|
69
- category.posts.map(&:name)
70
- category.entries.map(&:name)
71
- end
72
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
73
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
74
-
75
- expect(Bullet::Detector::Association).not_to be_detecting_unpreloaded_association_for(
76
- Mongoid::Category,
77
- :posts
78
- )
79
- expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Mongoid::Category, :entries)
80
- end
81
-
82
- it 'should detect preload with category => [posts, entries]' do
83
- Mongoid::Category.includes(:posts, :entries).each do |category|
84
- category.posts.map(&:name)
85
- category.entries.map(&:name)
86
- end
87
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
88
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
89
-
90
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
91
- end
92
-
93
- it 'should detect unused preload with category => [posts, entries]' do
94
- Mongoid::Category.includes(:posts, :entries).map(&:name)
95
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
96
- expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Mongoid::Category, :posts)
97
- expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Mongoid::Category, :entries)
98
-
99
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
100
- end
101
-
102
- it 'should detect unused preload with category => entries, but not with category => posts' do
103
- Mongoid::Category.includes(:posts, :entries).each { |category| category.posts.map(&:name) }
104
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
105
- expect(Bullet::Detector::Association).not_to be_unused_preload_associations_for(Mongoid::Category, :posts)
106
- expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Mongoid::Category, :entries)
107
-
108
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
109
- end
110
- end
111
-
112
- context 'post => comment' do
113
- it 'should detect unused preload with post => comments' do
114
- Mongoid::Post.includes(:comments).each { |post| post.comments.first.name }
115
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
116
- expect(Bullet::Detector::Association).not_to be_unused_preload_associations_for(Mongoid::Post, :comments)
117
-
118
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
119
- end
120
-
121
- it 'should detect preload with post => comments' do
122
- Mongoid::Post.first.comments.map(&:name)
123
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
124
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
125
-
126
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
127
- end
128
- end
129
-
130
- context 'scope preload_comments' do
131
- it 'should detect preload post => comments with scope' do
132
- Mongoid::Post.preload_comments.each { |post| post.comments.map(&:name) }
133
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
134
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
135
-
136
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
137
- end
138
-
139
- it 'should detect unused preload with scope' do
140
- Mongoid::Post.preload_comments.map(&:name)
141
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
142
- expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Mongoid::Post, :comments)
143
-
144
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
145
- end
146
- end
147
- end
148
-
149
- context 'belongs_to' do
150
- context 'comment => post' do
151
- it 'should detect non preload with comment => post' do
152
- Mongoid::Comment.all.each { |comment| comment.post.name }
153
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
154
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
155
-
156
- expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Mongoid::Comment, :post)
157
- end
158
-
159
- it 'should detect preload with one comment => post' do
160
- Mongoid::Comment.first.post.name
161
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
162
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
163
-
164
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
165
- end
166
-
167
- it 'should detect preload with comment => post' do
168
- Mongoid::Comment.includes(:post).each { |comment| comment.post.name }
169
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
170
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
171
-
172
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
173
- end
174
-
175
- it 'should not detect preload with comment => post' do
176
- Mongoid::Comment.all.map(&:name)
177
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
178
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
179
-
180
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
181
- end
182
-
183
- it 'should detect unused preload with comments => post' do
184
- Mongoid::Comment.includes(:post).map(&:name)
185
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
186
- expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Mongoid::Comment, :post)
187
-
188
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
189
- end
190
- end
191
- end
192
-
193
- context 'has_one' do
194
- context 'company => address' do
195
- if Mongoid::VERSION !~ /\A3.0/
196
- it 'should detect non preload association' do
197
- Mongoid::Company.all.each { |company| company.address.name }
198
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
199
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
200
-
201
- expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(
202
- Mongoid::Company,
203
- :address
204
- )
205
- end
206
- end
207
-
208
- it 'should detect preload association' do
209
- Mongoid::Company.includes(:address).each { |company| company.address.name }
210
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
211
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
212
-
213
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
214
- end
215
-
216
- it 'should not detect preload association' do
217
- Mongoid::Company.all.map(&:name)
218
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
219
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
220
-
221
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
222
- end
223
-
224
- it 'should detect unused preload association' do
225
- criteria = Mongoid::Company.includes(:address)
226
- criteria.map(&:name)
227
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
228
- expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Mongoid::Company, :address)
229
-
230
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
231
- end
232
- end
233
- end
234
-
235
- context 'call one association that in possible objects' do
236
- it 'should not detect preload association' do
237
- Mongoid::Post.all
238
- Mongoid::Post.first.comments.map(&:name)
239
- Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
240
- expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
241
-
242
- expect(Bullet::Detector::Association).to be_completely_preloading_associations
243
- end
244
- end
245
- end
246
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Address < ActiveRecord::Base
4
- belongs_to :company
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Attachment < ActiveRecord::Base
4
- belongs_to :submission
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Author < ActiveRecord::Base
4
- has_many :documents
5
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class BaseUser < ActiveRecord::Base
4
- has_many :comments
5
- has_many :posts
6
- belongs_to :newspaper
7
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Category < ActiveRecord::Base
4
- has_many :posts, inverse_of: :category
5
- has_many :entries
6
-
7
- has_many :users
8
-
9
- def draft_post
10
- posts.draft.first_or_create
11
- end
12
- end
data/spec/models/city.rb DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class City < ActiveRecord::Base
4
- belongs_to :country
5
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Client < ActiveRecord::Base
4
- belongs_to :group
5
-
6
- has_many :relationships
7
- has_many :firms, through: :relationships
8
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Comment < ActiveRecord::Base
4
- belongs_to :post, inverse_of: :comments
5
- belongs_to :author, class_name: 'BaseUser'
6
-
7
- validates :post, presence: true
8
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Company < ActiveRecord::Base
4
- has_one :address
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Country < ActiveRecord::Base
4
- has_many :cities
5
- end
data/spec/models/deal.rb DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Deal < ActiveRecord::Base
4
- has_and_belongs_to_many :posts
5
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Document < ActiveRecord::Base
4
- has_many :children, class_name: 'Document', foreign_key: 'parent_id'
5
- belongs_to :parent, class_name: 'Document', foreign_key: 'parent_id'
6
- belongs_to :author
7
- end
data/spec/models/entry.rb DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Entry < ActiveRecord::Base
4
- belongs_to :category
5
- end
data/spec/models/firm.rb DELETED
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Firm < ActiveRecord::Base
4
- has_many :relationships
5
- has_many :clients, through: :relationships
6
- has_many :groups, through: :clients
7
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Folder < Document
4
- end
data/spec/models/group.rb DELETED
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Group < ActiveRecord::Base
4
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Mongoid::Address
4
- include Mongoid::Document
5
-
6
- field :name
7
-
8
- belongs_to :company, class_name: 'Mongoid::Company'
9
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Mongoid::Category
4
- include Mongoid::Document
5
-
6
- field :name
7
-
8
- has_many :posts, class_name: 'Mongoid::Post'
9
- has_many :entries, class_name: 'Mongoid::Entry'
10
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Mongoid::Comment
4
- include Mongoid::Document
5
-
6
- field :name
7
-
8
- belongs_to :post, class_name: 'Mongoid::Post'
9
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Mongoid::Company
4
- include Mongoid::Document
5
-
6
- field :name
7
-
8
- has_one :address, class_name: 'Mongoid::Address'
9
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Mongoid::Entry
4
- include Mongoid::Document
5
-
6
- field :name
7
-
8
- belongs_to :category, class_name: 'Mongoid::Category'
9
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Mongoid::Post
4
- include Mongoid::Document
5
-
6
- field :name
7
-
8
- has_many :comments, class_name: 'Mongoid::Comment'
9
- belongs_to :category, class_name: 'Mongoid::Category'
10
-
11
- embeds_many :users, class_name: 'Mongoid::User'
12
-
13
- scope :preload_comments, -> { includes(:comments) }
14
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Mongoid::User
4
- include Mongoid::Document
5
-
6
- field :name
7
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Newspaper < ActiveRecord::Base
4
- has_many :writers, class_name: 'BaseUser'
5
- end
data/spec/models/page.rb DELETED
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Page < Document
4
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Person < ActiveRecord::Base
4
- has_many :pets
5
- end
data/spec/models/pet.rb DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Pet < ActiveRecord::Base
4
- belongs_to :person, counter_cache: true
5
- end
data/spec/models/post.rb DELETED
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Post < ActiveRecord::Base
4
- belongs_to :category, inverse_of: :posts
5
- belongs_to :writer
6
- has_many :comments, inverse_of: :post
7
- has_and_belongs_to_many :deals
8
-
9
- validates :category, presence: true
10
-
11
- scope :preload_comments, -> { includes(:comments) }
12
- scope :in_category_name, ->(name) { where(['categories.name = ?', name]).includes(:category) }
13
- scope :draft, -> { where(active: false) }
14
-
15
- def link=(*)
16
- comments.new
17
- end
18
-
19
- # see association_spec.rb 'should not detect newly assigned object in an after_save'
20
- attr_accessor :trigger_after_save
21
- after_save do
22
- next unless trigger_after_save
23
-
24
- temp_comment = Comment.new(post: self)
25
-
26
- # this triggers self to be "possible", even though it's
27
- # not saved yet
28
- temp_comment.post
29
-
30
- # category should NOT whine about not being pre-loaded, because
31
- # it's obviously attached to a new object
32
- category
33
- end
34
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Relationship < ActiveRecord::Base
4
- belongs_to :firm
5
- belongs_to :client
6
- end
data/spec/models/reply.rb DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Reply < ActiveRecord::Base
4
- belongs_to :submission
5
- end
data/spec/models/role.rb DELETED
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Role < ActiveRecord::Base
4
- has_and_belongs_to_many :users
5
-
6
- belongs_to :resource, polymorphic: true
7
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Student < ActiveRecord::Base
4
- has_and_belongs_to_many :teachers
5
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Submission < ActiveRecord::Base
4
- belongs_to :user
5
- has_many :replies
6
- has_one :attachment
7
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Teacher < ActiveRecord::Base
4
- has_and_belongs_to_many :students
5
- end
data/spec/models/user.rb DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class User < ActiveRecord::Base
4
- has_one :submission
5
- has_one :submission_attachment, through: :submission, source: :attachment, class_name: 'Attachment'
6
- belongs_to :category
7
- has_and_belongs_to_many :roles
8
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Writer < BaseUser
4
- end