pg_search 2.3.5 → 2.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +80 -0
- data/.standard.yml +6 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile +19 -6
- data/LICENSE +1 -1
- data/README.md +61 -39
- data/Rakefile +9 -6
- data/lib/pg_search/configuration/column.rb +6 -4
- data/lib/pg_search/configuration/foreign_column.rb +1 -1
- data/lib/pg_search/configuration.rb +13 -3
- data/lib/pg_search/document.rb +8 -8
- data/lib/pg_search/features/dmetaphone.rb +1 -1
- data/lib/pg_search/features/feature.rb +1 -1
- data/lib/pg_search/features/trigram.rb +4 -4
- data/lib/pg_search/features/tsearch.rb +15 -14
- data/lib/pg_search/migration/dmetaphone_generator.rb +2 -2
- data/lib/pg_search/migration/generator.rb +5 -5
- data/lib/pg_search/migration/multisearch_generator.rb +2 -2
- data/lib/pg_search/model.rb +6 -6
- data/lib/pg_search/multisearch.rb +16 -6
- data/lib/pg_search/multisearchable.rb +7 -7
- data/lib/pg_search/normalizer.rb +5 -5
- data/lib/pg_search/scope_options.rb +28 -10
- data/lib/pg_search/tasks.rb +2 -2
- data/lib/pg_search/version.rb +1 -1
- data/lib/pg_search.rb +5 -5
- data/pg_search.gemspec +17 -29
- data/spec/.rubocop.yml +20 -7
- data/spec/integration/.rubocop.yml +2 -2
- data/spec/integration/associations_spec.rb +106 -106
- data/spec/integration/deprecation_spec.rb +7 -8
- data/spec/integration/pg_search_spec.rb +339 -292
- data/spec/integration/single_table_inheritance_spec.rb +5 -5
- data/spec/lib/pg_search/configuration/association_spec.rb +15 -15
- data/spec/lib/pg_search/configuration/column_spec.rb +13 -1
- data/spec/lib/pg_search/configuration/foreign_column_spec.rb +4 -4
- data/spec/lib/pg_search/features/dmetaphone_spec.rb +4 -4
- data/spec/lib/pg_search/features/trigram_spec.rb +28 -28
- data/spec/lib/pg_search/features/tsearch_spec.rb +57 -39
- data/spec/lib/pg_search/multisearch/rebuilder_spec.rb +17 -17
- data/spec/lib/pg_search/multisearch_spec.rb +15 -6
- data/spec/lib/pg_search/multisearchable_spec.rb +26 -26
- data/spec/lib/pg_search/normalizer_spec.rb +7 -7
- data/spec/lib/pg_search_spec.rb +20 -20
- data/spec/spec_helper.rb +15 -9
- data/spec/support/database.rb +9 -7
- metadata +13 -188
- data/.autotest +0 -5
- data/.codeclimate.yml +0 -17
- data/.rubocop.yml +0 -134
- data/.travis.yml +0 -42
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
#
|
5
|
+
# standard:disable RSpec/NestedGroups
|
6
6
|
describe "a pg_search_scope" do
|
7
7
|
context "when joining to another table" do
|
8
8
|
context "without an :against" do
|
@@ -20,23 +20,23 @@ describe "a pg_search_scope" do
|
|
20
20
|
|
21
21
|
model do
|
22
22
|
include PgSearch::Model
|
23
|
-
belongs_to :another_model, class_name:
|
23
|
+
belongs_to :another_model, class_name: "AssociatedModel"
|
24
24
|
|
25
|
-
pg_search_scope :with_another, associated_against: {
|
25
|
+
pg_search_scope :with_another, associated_against: {another_model: :title}
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns rows that match the query in the columns of the associated model only" do
|
30
|
-
associated = AssociatedModel.create!(title:
|
30
|
+
associated = AssociatedModel.create!(title: "abcdef")
|
31
31
|
included = [
|
32
|
-
ModelWithoutAgainst.create!(title:
|
33
|
-
ModelWithoutAgainst.create!(title:
|
32
|
+
ModelWithoutAgainst.create!(title: "abcdef", another_model: associated),
|
33
|
+
ModelWithoutAgainst.create!(title: "ghijkl", another_model: associated)
|
34
34
|
]
|
35
35
|
excluded = [
|
36
|
-
ModelWithoutAgainst.create!(title:
|
36
|
+
ModelWithoutAgainst.create!(title: "abcdef")
|
37
37
|
]
|
38
38
|
|
39
|
-
results = ModelWithoutAgainst.with_another(
|
39
|
+
results = ModelWithoutAgainst.with_another("abcdef")
|
40
40
|
expect(results.map(&:title)).to match_array(included.map(&:title))
|
41
41
|
expect(results).not_to include(excluded)
|
42
42
|
end
|
@@ -45,34 +45,34 @@ describe "a pg_search_scope" do
|
|
45
45
|
context "via a belongs_to association" do
|
46
46
|
with_model :AssociatedModel do
|
47
47
|
table do |t|
|
48
|
-
t.string
|
48
|
+
t.string "title"
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
with_model :ModelWithBelongsTo do
|
53
53
|
table do |t|
|
54
|
-
t.string
|
55
|
-
t.belongs_to
|
54
|
+
t.string "title"
|
55
|
+
t.belongs_to "another_model", index: false
|
56
56
|
end
|
57
57
|
|
58
58
|
model do
|
59
59
|
include PgSearch::Model
|
60
|
-
belongs_to :another_model, class_name:
|
60
|
+
belongs_to :another_model, class_name: "AssociatedModel"
|
61
61
|
|
62
|
-
pg_search_scope :with_associated, against: :title, associated_against: {
|
62
|
+
pg_search_scope :with_associated, against: :title, associated_against: {another_model: :title}
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
it "returns rows that match the query in either its own columns or the columns of the associated model" do
|
67
|
-
associated = AssociatedModel.create!(title:
|
67
|
+
associated = AssociatedModel.create!(title: "abcdef")
|
68
68
|
included = [
|
69
|
-
ModelWithBelongsTo.create!(title:
|
70
|
-
ModelWithBelongsTo.create!(title:
|
69
|
+
ModelWithBelongsTo.create!(title: "ghijkl", another_model: associated),
|
70
|
+
ModelWithBelongsTo.create!(title: "abcdef")
|
71
71
|
]
|
72
|
-
excluded = ModelWithBelongsTo.create!(title:
|
73
|
-
|
72
|
+
excluded = ModelWithBelongsTo.create!(title: "mnopqr",
|
73
|
+
another_model: AssociatedModel.create!(title: "stuvwx"))
|
74
74
|
|
75
|
-
results = ModelWithBelongsTo.with_associated(
|
75
|
+
results = ModelWithBelongsTo.with_associated("abcdef")
|
76
76
|
expect(results.map(&:title)).to match_array(included.map(&:title))
|
77
77
|
expect(results).not_to include(excluded)
|
78
78
|
end
|
@@ -81,61 +81,61 @@ describe "a pg_search_scope" do
|
|
81
81
|
context "via a has_many association" do
|
82
82
|
with_model :AssociatedModelWithHasMany do
|
83
83
|
table do |t|
|
84
|
-
t.string
|
85
|
-
t.belongs_to
|
84
|
+
t.string "title"
|
85
|
+
t.belongs_to "ModelWithHasMany", index: false
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
89
|
with_model :ModelWithHasMany do
|
90
90
|
table do |t|
|
91
|
-
t.string
|
91
|
+
t.string "title"
|
92
92
|
end
|
93
93
|
|
94
94
|
model do
|
95
95
|
include PgSearch::Model
|
96
|
-
has_many :other_models, class_name:
|
96
|
+
has_many :other_models, class_name: "AssociatedModelWithHasMany", foreign_key: "ModelWithHasMany_id"
|
97
97
|
|
98
|
-
pg_search_scope :with_associated, against: [:title], associated_against: {
|
98
|
+
pg_search_scope :with_associated, against: [:title], associated_against: {other_models: :title}
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
it "returns rows that match the query in either its own columns or the columns of the associated model" do
|
103
103
|
included = [
|
104
|
-
ModelWithHasMany.create!(title:
|
105
|
-
AssociatedModelWithHasMany.create!(title:
|
106
|
-
AssociatedModelWithHasMany.create!(title:
|
104
|
+
ModelWithHasMany.create!(title: "abcdef", other_models: [
|
105
|
+
AssociatedModelWithHasMany.create!(title: "foo"),
|
106
|
+
AssociatedModelWithHasMany.create!(title: "bar")
|
107
107
|
]),
|
108
|
-
ModelWithHasMany.create!(title:
|
109
|
-
AssociatedModelWithHasMany.create!(title:
|
110
|
-
AssociatedModelWithHasMany.create!(title:
|
108
|
+
ModelWithHasMany.create!(title: "ghijkl", other_models: [
|
109
|
+
AssociatedModelWithHasMany.create!(title: "foo bar"),
|
110
|
+
AssociatedModelWithHasMany.create!(title: "mnopqr")
|
111
111
|
]),
|
112
|
-
ModelWithHasMany.create!(title:
|
112
|
+
ModelWithHasMany.create!(title: "foo bar")
|
113
113
|
]
|
114
|
-
excluded = ModelWithHasMany.create!(title:
|
115
|
-
AssociatedModelWithHasMany.create!(title:
|
114
|
+
excluded = ModelWithHasMany.create!(title: "stuvwx", other_models: [
|
115
|
+
AssociatedModelWithHasMany.create!(title: "abcdef")
|
116
116
|
])
|
117
117
|
|
118
|
-
results = ModelWithHasMany.with_associated(
|
118
|
+
results = ModelWithHasMany.with_associated("foo bar")
|
119
119
|
expect(results.map(&:title)).to match_array(included.map(&:title))
|
120
120
|
expect(results).not_to include(excluded)
|
121
121
|
end
|
122
122
|
|
123
123
|
it "uses an unscoped relation of the associated model" do
|
124
|
-
excluded = ModelWithHasMany.create!(title:
|
125
|
-
AssociatedModelWithHasMany.create!(title:
|
124
|
+
excluded = ModelWithHasMany.create!(title: "abcdef", other_models: [
|
125
|
+
AssociatedModelWithHasMany.create!(title: "abcdef")
|
126
126
|
])
|
127
127
|
|
128
128
|
included = [
|
129
|
-
ModelWithHasMany.create!(title:
|
130
|
-
AssociatedModelWithHasMany.create!(title:
|
131
|
-
AssociatedModelWithHasMany.create!(title:
|
129
|
+
ModelWithHasMany.create!(title: "abcdef", other_models: [
|
130
|
+
AssociatedModelWithHasMany.create!(title: "foo"),
|
131
|
+
AssociatedModelWithHasMany.create!(title: "bar")
|
132
132
|
])
|
133
133
|
]
|
134
134
|
|
135
135
|
results = ModelWithHasMany
|
136
|
-
|
137
|
-
|
138
|
-
|
136
|
+
.limit(1)
|
137
|
+
.order(Arel.sql("#{ModelWithHasMany.quoted_table_name}.id ASC"))
|
138
|
+
.with_associated("foo bar")
|
139
139
|
|
140
140
|
expect(results.map(&:title)).to match_array(included.map(&:title))
|
141
141
|
expect(results).not_to include(excluded)
|
@@ -146,36 +146,36 @@ describe "a pg_search_scope" do
|
|
146
146
|
context "when on different tables" do
|
147
147
|
with_model :FirstAssociatedModel do
|
148
148
|
table do |t|
|
149
|
-
t.string
|
150
|
-
t.belongs_to
|
149
|
+
t.string "title"
|
150
|
+
t.belongs_to "ModelWithManyAssociations", index: false
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
154
154
|
with_model :SecondAssociatedModel do
|
155
155
|
table do |t|
|
156
|
-
t.string
|
156
|
+
t.string "title"
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
160
|
with_model :ModelWithManyAssociations do
|
161
161
|
table do |t|
|
162
|
-
t.string
|
163
|
-
t.belongs_to
|
162
|
+
t.string "title"
|
163
|
+
t.belongs_to "model_of_second_type", index: false
|
164
164
|
end
|
165
165
|
|
166
166
|
model do
|
167
167
|
include PgSearch::Model
|
168
168
|
|
169
169
|
has_many :models_of_first_type,
|
170
|
-
|
171
|
-
|
170
|
+
class_name: "FirstAssociatedModel",
|
171
|
+
foreign_key: "ModelWithManyAssociations_id"
|
172
172
|
|
173
173
|
belongs_to :model_of_second_type,
|
174
|
-
|
174
|
+
class_name: "SecondAssociatedModel"
|
175
175
|
|
176
176
|
pg_search_scope :with_associated,
|
177
|
-
|
178
|
-
|
177
|
+
against: :title,
|
178
|
+
associated_against: {models_of_first_type: :title, model_of_second_type: :title}
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
@@ -184,25 +184,25 @@ describe "a pg_search_scope" do
|
|
184
184
|
unmatching_second = SecondAssociatedModel.create!(title: "uiop")
|
185
185
|
|
186
186
|
included = [
|
187
|
-
ModelWithManyAssociations.create!(title:
|
188
|
-
FirstAssociatedModel.create!(title:
|
189
|
-
FirstAssociatedModel.create!(title:
|
187
|
+
ModelWithManyAssociations.create!(title: "abcdef", models_of_first_type: [
|
188
|
+
FirstAssociatedModel.create!(title: "foo"),
|
189
|
+
FirstAssociatedModel.create!(title: "bar")
|
190
190
|
]),
|
191
|
-
ModelWithManyAssociations.create!(title:
|
192
|
-
FirstAssociatedModel.create!(title:
|
193
|
-
FirstAssociatedModel.create!(title:
|
191
|
+
ModelWithManyAssociations.create!(title: "ghijkl", models_of_first_type: [
|
192
|
+
FirstAssociatedModel.create!(title: "foo bar"),
|
193
|
+
FirstAssociatedModel.create!(title: "mnopqr")
|
194
194
|
]),
|
195
|
-
ModelWithManyAssociations.create!(title:
|
196
|
-
ModelWithManyAssociations.create!(title:
|
195
|
+
ModelWithManyAssociations.create!(title: "foo bar"),
|
196
|
+
ModelWithManyAssociations.create!(title: "qwerty", model_of_second_type: matching_second)
|
197
197
|
]
|
198
198
|
excluded = [
|
199
|
-
ModelWithManyAssociations.create!(title:
|
200
|
-
FirstAssociatedModel.create!(title:
|
199
|
+
ModelWithManyAssociations.create!(title: "stuvwx", models_of_first_type: [
|
200
|
+
FirstAssociatedModel.create!(title: "abcdef")
|
201
201
|
]),
|
202
|
-
ModelWithManyAssociations.create!(title:
|
202
|
+
ModelWithManyAssociations.create!(title: "qwerty", model_of_second_type: unmatching_second)
|
203
203
|
]
|
204
204
|
|
205
|
-
results = ModelWithManyAssociations.with_associated(
|
205
|
+
results = ModelWithManyAssociations.with_associated("foo bar")
|
206
206
|
expect(results.map(&:title)).to match_array(included.map(&:title))
|
207
207
|
excluded.each { |object| expect(results).not_to include(object) }
|
208
208
|
end
|
@@ -211,58 +211,58 @@ describe "a pg_search_scope" do
|
|
211
211
|
context "when on the same table" do
|
212
212
|
with_model :DoublyAssociatedModel do
|
213
213
|
table do |t|
|
214
|
-
t.string
|
215
|
-
t.belongs_to
|
216
|
-
t.belongs_to
|
214
|
+
t.string "title"
|
215
|
+
t.belongs_to "ModelWithDoubleAssociation", index: false
|
216
|
+
t.belongs_to "ModelWithDoubleAssociation_again", index: false
|
217
217
|
end
|
218
218
|
end
|
219
219
|
|
220
220
|
with_model :ModelWithDoubleAssociation do
|
221
221
|
table do |t|
|
222
|
-
t.string
|
222
|
+
t.string "title"
|
223
223
|
end
|
224
224
|
|
225
225
|
model do
|
226
226
|
include PgSearch::Model
|
227
227
|
|
228
228
|
has_many :things,
|
229
|
-
|
230
|
-
|
229
|
+
class_name: "DoublyAssociatedModel",
|
230
|
+
foreign_key: "ModelWithDoubleAssociation_id"
|
231
231
|
|
232
232
|
has_many :thingamabobs,
|
233
|
-
|
234
|
-
|
233
|
+
class_name: "DoublyAssociatedModel",
|
234
|
+
foreign_key: "ModelWithDoubleAssociation_again_id"
|
235
235
|
|
236
236
|
pg_search_scope :with_associated, against: :title,
|
237
|
-
|
237
|
+
associated_against: {things: :title, thingamabobs: :title}
|
238
238
|
end
|
239
239
|
end
|
240
240
|
|
241
241
|
it "returns rows that match the query in either its own columns or the columns of the associated model" do
|
242
242
|
included = [
|
243
|
-
ModelWithDoubleAssociation.create!(title:
|
244
|
-
DoublyAssociatedModel.create!(title:
|
245
|
-
DoublyAssociatedModel.create!(title:
|
243
|
+
ModelWithDoubleAssociation.create!(title: "abcdef", things: [
|
244
|
+
DoublyAssociatedModel.create!(title: "foo"),
|
245
|
+
DoublyAssociatedModel.create!(title: "bar")
|
246
246
|
]),
|
247
|
-
ModelWithDoubleAssociation.create!(title:
|
248
|
-
DoublyAssociatedModel.create!(title:
|
249
|
-
DoublyAssociatedModel.create!(title:
|
247
|
+
ModelWithDoubleAssociation.create!(title: "ghijkl", things: [
|
248
|
+
DoublyAssociatedModel.create!(title: "foo bar"),
|
249
|
+
DoublyAssociatedModel.create!(title: "mnopqr")
|
250
250
|
]),
|
251
|
-
ModelWithDoubleAssociation.create!(title:
|
252
|
-
ModelWithDoubleAssociation.create!(title:
|
251
|
+
ModelWithDoubleAssociation.create!(title: "foo bar"),
|
252
|
+
ModelWithDoubleAssociation.create!(title: "qwerty", thingamabobs: [
|
253
253
|
DoublyAssociatedModel.create!(title: "foo bar")
|
254
254
|
])
|
255
255
|
]
|
256
256
|
excluded = [
|
257
|
-
ModelWithDoubleAssociation.create!(title:
|
258
|
-
DoublyAssociatedModel.create!(title:
|
257
|
+
ModelWithDoubleAssociation.create!(title: "stuvwx", things: [
|
258
|
+
DoublyAssociatedModel.create!(title: "abcdef")
|
259
259
|
]),
|
260
|
-
ModelWithDoubleAssociation.create!(title:
|
260
|
+
ModelWithDoubleAssociation.create!(title: "qwerty", thingamabobs: [
|
261
261
|
DoublyAssociatedModel.create!(title: "uiop")
|
262
262
|
])
|
263
263
|
]
|
264
264
|
|
265
|
-
results = ModelWithDoubleAssociation.with_associated(
|
265
|
+
results = ModelWithDoubleAssociation.with_associated("foo bar")
|
266
266
|
expect(results.map(&:title)).to match_array(included.map(&:title))
|
267
267
|
excluded.each { |object| expect(results).not_to include(object) }
|
268
268
|
end
|
@@ -272,21 +272,21 @@ describe "a pg_search_scope" do
|
|
272
272
|
context "when against multiple attributes on one association" do
|
273
273
|
with_model :AssociatedModel do
|
274
274
|
table do |t|
|
275
|
-
t.string
|
276
|
-
t.text
|
275
|
+
t.string "title"
|
276
|
+
t.text "author"
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
280
280
|
with_model :ModelWithAssociation do
|
281
281
|
table do |t|
|
282
|
-
t.belongs_to
|
282
|
+
t.belongs_to "another_model", index: false
|
283
283
|
end
|
284
284
|
|
285
285
|
model do
|
286
286
|
include PgSearch::Model
|
287
|
-
belongs_to :another_model, class_name:
|
287
|
+
belongs_to :another_model, class_name: "AssociatedModel"
|
288
288
|
|
289
|
-
pg_search_scope :with_associated, associated_against: {
|
289
|
+
pg_search_scope :with_associated, associated_against: {another_model: %i[title author]}
|
290
290
|
end
|
291
291
|
end
|
292
292
|
|
@@ -314,7 +314,7 @@ describe "a pg_search_scope" do
|
|
314
314
|
)
|
315
315
|
]
|
316
316
|
|
317
|
-
results = ModelWithAssociation.with_associated(
|
317
|
+
results = ModelWithAssociation.with_associated("foo bar")
|
318
318
|
|
319
319
|
expect(results.to_sql.scan("INNER JOIN #{AssociatedModel.quoted_table_name}").length).to eq(1)
|
320
320
|
included.each { |object| expect(results).to include(object) }
|
@@ -325,21 +325,21 @@ describe "a pg_search_scope" do
|
|
325
325
|
context "when against non-text columns" do
|
326
326
|
with_model :AssociatedModel do
|
327
327
|
table do |t|
|
328
|
-
t.integer
|
328
|
+
t.integer "number"
|
329
329
|
end
|
330
330
|
end
|
331
331
|
|
332
332
|
with_model :Model do
|
333
333
|
table do |t|
|
334
|
-
t.integer
|
335
|
-
t.belongs_to
|
334
|
+
t.integer "number"
|
335
|
+
t.belongs_to "another_model", index: false
|
336
336
|
end
|
337
337
|
|
338
338
|
model do
|
339
339
|
include PgSearch::Model
|
340
|
-
belongs_to :another_model, class_name:
|
340
|
+
belongs_to :another_model, class_name: "AssociatedModel"
|
341
341
|
|
342
|
-
pg_search_scope :with_associated, associated_against: {
|
342
|
+
pg_search_scope :with_associated, associated_against: {another_model: :number}
|
343
343
|
end
|
344
344
|
end
|
345
345
|
|
@@ -353,7 +353,7 @@ describe "a pg_search_scope" do
|
|
353
353
|
Model.create!(number: 123)
|
354
354
|
]
|
355
355
|
|
356
|
-
results = Model.with_associated(
|
356
|
+
results = Model.with_associated("123")
|
357
357
|
expect(results.map(&:number)).to match_array(included.map(&:number))
|
358
358
|
expect(results).not_to include(excluded)
|
359
359
|
end
|
@@ -384,10 +384,10 @@ describe "a pg_search_scope" do
|
|
384
384
|
|
385
385
|
# https://github.com/Casecommons/pg_search/issues/14
|
386
386
|
it "supports queries with periods" do
|
387
|
-
included = Parent.create!(name:
|
388
|
-
excluded = Parent.create!(name:
|
387
|
+
included = Parent.create!(name: "bar.foo")
|
388
|
+
excluded = Parent.create!(name: "foo.bar")
|
389
389
|
|
390
|
-
results = Parent.search_name(
|
390
|
+
results = Parent.search_name("bar.foo").includes(:children)
|
391
391
|
results.to_a
|
392
392
|
|
393
393
|
expect(results).to include(included)
|
@@ -418,10 +418,10 @@ describe "a pg_search_scope" do
|
|
418
418
|
end
|
419
419
|
|
420
420
|
it "finds records of the other model" do
|
421
|
-
included_associated_1 = AssociatedModel.create(content: "foo bar")
|
422
|
-
included_associated_2 = AssociatedModel.create(content: "foo baz")
|
423
|
-
excluded_associated_1 = AssociatedModel.create(content: "baz quux")
|
424
|
-
excluded_associated_2 = AssociatedModel.create(content: "baz bar")
|
421
|
+
included_associated_1 = AssociatedModel.create!(content: "foo bar")
|
422
|
+
included_associated_2 = AssociatedModel.create!(content: "foo baz")
|
423
|
+
excluded_associated_1 = AssociatedModel.create!(content: "baz quux")
|
424
|
+
excluded_associated_2 = AssociatedModel.create!(content: "baz bar")
|
425
425
|
|
426
426
|
included = [
|
427
427
|
ModelWithAssociation.create(associated_models: [included_associated_1]),
|
@@ -477,11 +477,11 @@ describe "a pg_search_scope" do
|
|
477
477
|
Position.create!(company_id: company.id, title: "penn 1")
|
478
478
|
]
|
479
479
|
|
480
|
-
results = company.positions.search(
|
480
|
+
results = company.positions.search("teller 1")
|
481
481
|
|
482
482
|
expect(results).to include(*included)
|
483
483
|
expect(results).not_to include(*excluded)
|
484
484
|
end
|
485
485
|
end
|
486
486
|
end
|
487
|
-
#
|
487
|
+
# standard:enable RSpec/NestedGroups
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
|
+
require "active_support/core_ext/kernel/reporting"
|
4
5
|
|
5
6
|
describe "Including the deprecated PgSearch module" do
|
6
7
|
with_model :SomeModel do
|
7
8
|
model do
|
8
|
-
|
9
|
+
silence_warnings do
|
9
10
|
include PgSearch
|
10
11
|
end
|
11
12
|
end
|
@@ -18,16 +19,14 @@ describe "Including the deprecated PgSearch module" do
|
|
18
19
|
end
|
19
20
|
|
20
21
|
it "prints a deprecation message" do
|
21
|
-
allow(
|
22
|
+
allow(PgSearch).to receive(:warn)
|
22
23
|
|
23
24
|
AnotherModel.include(PgSearch)
|
24
25
|
|
25
|
-
expect(
|
26
|
-
|
27
|
-
Directly including `PgSearch` into an Active Record model is deprecated and will be removed in pg_search 3.0.
|
26
|
+
expect(PgSearch).to have_received(:warn).with(<<~MESSAGE, category: :deprecated, uplevel: 1)
|
27
|
+
Directly including `PgSearch` into an Active Record model is deprecated and will be removed in pg_search 3.0.
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
)
|
29
|
+
Please replace `include PgSearch` with `include PgSearch::Model`.
|
30
|
+
MESSAGE
|
32
31
|
end
|
33
32
|
end
|