pg_search 2.1.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +11 -7
- data/.travis.yml +33 -42
- data/CHANGELOG.md +140 -112
- data/CONTRIBUTING.md +5 -3
- data/Gemfile +6 -4
- data/LICENSE +1 -1
- data/README.md +221 -159
- data/Rakefile +3 -5
- data/lib/pg_search/configuration/association.rb +2 -0
- data/lib/pg_search/configuration/column.rb +2 -0
- data/lib/pg_search/configuration/foreign_column.rb +2 -0
- data/lib/pg_search/configuration.rb +8 -4
- data/lib/pg_search/document.rb +5 -3
- data/lib/pg_search/features/dmetaphone.rb +3 -1
- data/lib/pg_search/features/feature.rb +4 -2
- data/lib/pg_search/features/trigram.rb +31 -5
- data/lib/pg_search/features/tsearch.rb +4 -1
- data/lib/pg_search/features.rb +2 -0
- data/lib/pg_search/migration/dmetaphone_generator.rb +3 -1
- data/lib/pg_search/migration/generator.rb +4 -2
- data/lib/pg_search/migration/multisearch_generator.rb +2 -1
- data/lib/pg_search/migration/templates/create_pg_search_documents.rb.erb +1 -1
- data/lib/pg_search/multisearch/rebuilder.rb +7 -3
- data/lib/pg_search/multisearch.rb +4 -4
- data/lib/pg_search/multisearchable.rb +10 -6
- data/lib/pg_search/normalizer.rb +2 -0
- data/lib/pg_search/railtie.rb +2 -0
- data/lib/pg_search/scope_options.rb +21 -41
- data/lib/pg_search/tasks.rb +3 -0
- data/lib/pg_search/version.rb +3 -1
- data/lib/pg_search.rb +10 -5
- data/pg_search.gemspec +8 -7
- data/spec/integration/associations_spec.rb +103 -101
- data/spec/integration/pagination_spec.rb +9 -7
- data/spec/integration/pg_search_spec.rb +266 -255
- data/spec/integration/single_table_inheritance_spec.rb +16 -15
- data/spec/lib/pg_search/configuration/association_spec.rb +7 -5
- data/spec/lib/pg_search/configuration/column_spec.rb +2 -0
- data/spec/lib/pg_search/configuration/foreign_column_spec.rb +5 -3
- data/spec/lib/pg_search/features/dmetaphone_spec.rb +6 -4
- data/spec/lib/pg_search/features/trigram_spec.rb +39 -12
- data/spec/lib/pg_search/features/tsearch_spec.rb +23 -21
- data/spec/lib/pg_search/multisearch/rebuilder_spec.rb +32 -11
- data/spec/lib/pg_search/multisearch_spec.rb +9 -7
- data/spec/lib/pg_search/multisearchable_spec.rb +68 -27
- data/spec/lib/pg_search/normalizer_spec.rb +7 -5
- data/spec/lib/pg_search_spec.rb +33 -31
- data/spec/spec_helper.rb +3 -1
- data/spec/support/database.rb +16 -20
- data/spec/support/with_model.rb +2 -0
- metadata +13 -30
- data/.rubocop_todo.yml +0 -163
- data/Guardfile +0 -6
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe PgSearch do
|
@@ -12,25 +14,25 @@ describe PgSearch do
|
|
12
14
|
with_model :ModelWithoutAgainst do
|
13
15
|
table do |t|
|
14
16
|
t.string "title"
|
15
|
-
t.belongs_to :another_model, :
|
17
|
+
t.belongs_to :another_model, index: false
|
16
18
|
end
|
17
19
|
|
18
20
|
model do
|
19
21
|
include PgSearch
|
20
|
-
belongs_to :another_model, :
|
22
|
+
belongs_to :another_model, class_name: 'AssociatedModel'
|
21
23
|
|
22
|
-
pg_search_scope :with_another, :
|
24
|
+
pg_search_scope :with_another, associated_against: { another_model: :title }
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
28
|
it "returns rows that match the query in the columns of the associated model only" do
|
27
|
-
associated = AssociatedModel.create!(:
|
29
|
+
associated = AssociatedModel.create!(title: 'abcdef')
|
28
30
|
included = [
|
29
|
-
ModelWithoutAgainst.create!(:
|
30
|
-
ModelWithoutAgainst.create!(:
|
31
|
+
ModelWithoutAgainst.create!(title: 'abcdef', another_model: associated),
|
32
|
+
ModelWithoutAgainst.create!(title: 'ghijkl', another_model: associated)
|
31
33
|
]
|
32
34
|
excluded = [
|
33
|
-
ModelWithoutAgainst.create!(:
|
35
|
+
ModelWithoutAgainst.create!(title: 'abcdef')
|
34
36
|
]
|
35
37
|
|
36
38
|
results = ModelWithoutAgainst.with_another('abcdef')
|
@@ -54,20 +56,20 @@ describe PgSearch do
|
|
54
56
|
|
55
57
|
model do
|
56
58
|
include PgSearch
|
57
|
-
belongs_to :another_model, :
|
59
|
+
belongs_to :another_model, class_name: 'AssociatedModel'
|
58
60
|
|
59
|
-
pg_search_scope :with_associated, :
|
61
|
+
pg_search_scope :with_associated, against: :title, associated_against: { another_model: :title }
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
63
65
|
it "returns rows that match the query in either its own columns or the columns of the associated model" do
|
64
|
-
associated = AssociatedModel.create!(:
|
66
|
+
associated = AssociatedModel.create!(title: 'abcdef')
|
65
67
|
included = [
|
66
|
-
ModelWithBelongsTo.create!(:
|
67
|
-
ModelWithBelongsTo.create!(:
|
68
|
+
ModelWithBelongsTo.create!(title: 'ghijkl', another_model: associated),
|
69
|
+
ModelWithBelongsTo.create!(title: 'abcdef')
|
68
70
|
]
|
69
|
-
excluded = ModelWithBelongsTo.create!(:
|
70
|
-
:
|
71
|
+
excluded = ModelWithBelongsTo.create!(title: 'mnopqr',
|
72
|
+
another_model: AssociatedModel.create!(title: 'stuvwx'))
|
71
73
|
|
72
74
|
results = ModelWithBelongsTo.with_associated('abcdef')
|
73
75
|
expect(results.map(&:title)).to match_array(included.map(&:title))
|
@@ -90,26 +92,26 @@ describe PgSearch do
|
|
90
92
|
|
91
93
|
model do
|
92
94
|
include PgSearch
|
93
|
-
has_many :other_models, :
|
95
|
+
has_many :other_models, class_name: 'AssociatedModelWithHasMany', foreign_key: 'ModelWithHasMany_id'
|
94
96
|
|
95
|
-
pg_search_scope :with_associated, :
|
97
|
+
pg_search_scope :with_associated, against: [:title], associated_against: { other_models: :title }
|
96
98
|
end
|
97
99
|
end
|
98
100
|
|
99
101
|
it "returns rows that match the query in either its own columns or the columns of the associated model" do
|
100
102
|
included = [
|
101
|
-
ModelWithHasMany.create!(:
|
102
|
-
AssociatedModelWithHasMany.create!(:
|
103
|
-
AssociatedModelWithHasMany.create!(:
|
103
|
+
ModelWithHasMany.create!(title: 'abcdef', other_models: [
|
104
|
+
AssociatedModelWithHasMany.create!(title: 'foo'),
|
105
|
+
AssociatedModelWithHasMany.create!(title: 'bar')
|
104
106
|
]),
|
105
|
-
ModelWithHasMany.create!(:
|
106
|
-
AssociatedModelWithHasMany.create!(:
|
107
|
-
AssociatedModelWithHasMany.create!(:
|
107
|
+
ModelWithHasMany.create!(title: 'ghijkl', other_models: [
|
108
|
+
AssociatedModelWithHasMany.create!(title: 'foo bar'),
|
109
|
+
AssociatedModelWithHasMany.create!(title: 'mnopqr')
|
108
110
|
]),
|
109
|
-
ModelWithHasMany.create!(:
|
111
|
+
ModelWithHasMany.create!(title: 'foo bar')
|
110
112
|
]
|
111
|
-
excluded = ModelWithHasMany.create!(:
|
112
|
-
AssociatedModelWithHasMany.create!(:
|
113
|
+
excluded = ModelWithHasMany.create!(title: 'stuvwx', other_models: [
|
114
|
+
AssociatedModelWithHasMany.create!(title: 'abcdef')
|
113
115
|
])
|
114
116
|
|
115
117
|
results = ModelWithHasMany.with_associated('foo bar')
|
@@ -118,14 +120,14 @@ describe PgSearch do
|
|
118
120
|
end
|
119
121
|
|
120
122
|
it "uses an unscoped relation of the associated model" do
|
121
|
-
excluded = ModelWithHasMany.create!(:
|
122
|
-
AssociatedModelWithHasMany.create!(:
|
123
|
+
excluded = ModelWithHasMany.create!(title: 'abcdef', other_models: [
|
124
|
+
AssociatedModelWithHasMany.create!(title: 'abcdef')
|
123
125
|
])
|
124
126
|
|
125
127
|
included = [
|
126
|
-
ModelWithHasMany.create!(:
|
127
|
-
AssociatedModelWithHasMany.create!(:
|
128
|
-
AssociatedModelWithHasMany.create!(:
|
128
|
+
ModelWithHasMany.create!(title: 'abcdef', other_models: [
|
129
|
+
AssociatedModelWithHasMany.create!(title: 'foo'),
|
130
|
+
AssociatedModelWithHasMany.create!(title: 'bar')
|
129
131
|
])
|
130
132
|
]
|
131
133
|
|
@@ -164,39 +166,39 @@ describe PgSearch do
|
|
164
166
|
include PgSearch
|
165
167
|
|
166
168
|
has_many :models_of_first_type,
|
167
|
-
|
168
|
-
|
169
|
+
class_name: 'FirstAssociatedModel',
|
170
|
+
foreign_key: 'ModelWithManyAssociations_id'
|
169
171
|
|
170
172
|
belongs_to :model_of_second_type,
|
171
|
-
|
173
|
+
class_name: 'SecondAssociatedModel'
|
172
174
|
|
173
175
|
pg_search_scope :with_associated,
|
174
|
-
|
175
|
-
|
176
|
+
against: :title,
|
177
|
+
associated_against: { models_of_first_type: :title, model_of_second_type: :title }
|
176
178
|
end
|
177
179
|
end
|
178
180
|
|
179
181
|
it "returns rows that match the query in either its own columns or the columns of the associated model" do
|
180
|
-
matching_second = SecondAssociatedModel.create!(:
|
181
|
-
unmatching_second = SecondAssociatedModel.create!(:
|
182
|
+
matching_second = SecondAssociatedModel.create!(title: "foo bar")
|
183
|
+
unmatching_second = SecondAssociatedModel.create!(title: "uiop")
|
182
184
|
|
183
185
|
included = [
|
184
|
-
ModelWithManyAssociations.create!(:
|
185
|
-
FirstAssociatedModel.create!(:
|
186
|
-
FirstAssociatedModel.create!(:
|
186
|
+
ModelWithManyAssociations.create!(title: 'abcdef', models_of_first_type: [
|
187
|
+
FirstAssociatedModel.create!(title: 'foo'),
|
188
|
+
FirstAssociatedModel.create!(title: 'bar')
|
187
189
|
]),
|
188
|
-
ModelWithManyAssociations.create!(:
|
189
|
-
FirstAssociatedModel.create!(:
|
190
|
-
FirstAssociatedModel.create!(:
|
190
|
+
ModelWithManyAssociations.create!(title: 'ghijkl', models_of_first_type: [
|
191
|
+
FirstAssociatedModel.create!(title: 'foo bar'),
|
192
|
+
FirstAssociatedModel.create!(title: 'mnopqr')
|
191
193
|
]),
|
192
|
-
ModelWithManyAssociations.create!(:
|
193
|
-
ModelWithManyAssociations.create!(:
|
194
|
+
ModelWithManyAssociations.create!(title: 'foo bar'),
|
195
|
+
ModelWithManyAssociations.create!(title: 'qwerty', model_of_second_type: matching_second)
|
194
196
|
]
|
195
197
|
excluded = [
|
196
|
-
ModelWithManyAssociations.create!(:
|
197
|
-
FirstAssociatedModel.create!(:
|
198
|
+
ModelWithManyAssociations.create!(title: 'stuvwx', models_of_first_type: [
|
199
|
+
FirstAssociatedModel.create!(title: 'abcdef')
|
198
200
|
]),
|
199
|
-
ModelWithManyAssociations.create!(:
|
201
|
+
ModelWithManyAssociations.create!(title: 'qwerty', model_of_second_type: unmatching_second)
|
200
202
|
]
|
201
203
|
|
202
204
|
results = ModelWithManyAssociations.with_associated('foo bar')
|
@@ -223,39 +225,39 @@ describe PgSearch do
|
|
223
225
|
include PgSearch
|
224
226
|
|
225
227
|
has_many :things,
|
226
|
-
|
227
|
-
|
228
|
+
class_name: 'DoublyAssociatedModel',
|
229
|
+
foreign_key: 'ModelWithDoubleAssociation_id'
|
228
230
|
|
229
231
|
has_many :thingamabobs,
|
230
|
-
|
231
|
-
|
232
|
+
class_name: 'DoublyAssociatedModel',
|
233
|
+
foreign_key: 'ModelWithDoubleAssociation_again_id'
|
232
234
|
|
233
|
-
pg_search_scope :with_associated, :
|
234
|
-
:
|
235
|
+
pg_search_scope :with_associated, against: :title,
|
236
|
+
associated_against: { things: :title, thingamabobs: :title }
|
235
237
|
end
|
236
238
|
end
|
237
239
|
|
238
240
|
it "returns rows that match the query in either its own columns or the columns of the associated model" do
|
239
241
|
included = [
|
240
|
-
ModelWithDoubleAssociation.create!(:
|
241
|
-
DoublyAssociatedModel.create!(:
|
242
|
-
DoublyAssociatedModel.create!(:
|
242
|
+
ModelWithDoubleAssociation.create!(title: 'abcdef', things: [
|
243
|
+
DoublyAssociatedModel.create!(title: 'foo'),
|
244
|
+
DoublyAssociatedModel.create!(title: 'bar')
|
243
245
|
]),
|
244
|
-
ModelWithDoubleAssociation.create!(:
|
245
|
-
DoublyAssociatedModel.create!(:
|
246
|
-
DoublyAssociatedModel.create!(:
|
246
|
+
ModelWithDoubleAssociation.create!(title: 'ghijkl', things: [
|
247
|
+
DoublyAssociatedModel.create!(title: 'foo bar'),
|
248
|
+
DoublyAssociatedModel.create!(title: 'mnopqr')
|
247
249
|
]),
|
248
|
-
ModelWithDoubleAssociation.create!(:
|
249
|
-
ModelWithDoubleAssociation.create!(:
|
250
|
-
DoublyAssociatedModel.create!(:
|
250
|
+
ModelWithDoubleAssociation.create!(title: 'foo bar'),
|
251
|
+
ModelWithDoubleAssociation.create!(title: 'qwerty', thingamabobs: [
|
252
|
+
DoublyAssociatedModel.create!(title: "foo bar")
|
251
253
|
])
|
252
254
|
]
|
253
255
|
excluded = [
|
254
|
-
ModelWithDoubleAssociation.create!(:
|
255
|
-
DoublyAssociatedModel.create!(:
|
256
|
+
ModelWithDoubleAssociation.create!(title: 'stuvwx', things: [
|
257
|
+
DoublyAssociatedModel.create!(title: 'abcdef')
|
256
258
|
]),
|
257
|
-
ModelWithDoubleAssociation.create!(:
|
258
|
-
DoublyAssociatedModel.create!(:
|
259
|
+
ModelWithDoubleAssociation.create!(title: 'qwerty', thingamabobs: [
|
260
|
+
DoublyAssociatedModel.create!(title: "uiop")
|
259
261
|
])
|
260
262
|
]
|
261
263
|
|
@@ -281,32 +283,32 @@ describe PgSearch do
|
|
281
283
|
|
282
284
|
model do
|
283
285
|
include PgSearch
|
284
|
-
belongs_to :another_model, :
|
286
|
+
belongs_to :another_model, class_name: 'AssociatedModel'
|
285
287
|
|
286
|
-
pg_search_scope :with_associated, :
|
288
|
+
pg_search_scope :with_associated, associated_against: { another_model: %i[title author] }
|
287
289
|
end
|
288
290
|
end
|
289
291
|
|
290
292
|
it "should only do one join" do
|
291
293
|
included = [
|
292
294
|
ModelWithAssociation.create!(
|
293
|
-
:
|
294
|
-
:
|
295
|
-
:
|
295
|
+
another_model: AssociatedModel.create!(
|
296
|
+
title: "foo",
|
297
|
+
author: "bar"
|
296
298
|
)
|
297
299
|
),
|
298
300
|
ModelWithAssociation.create!(
|
299
|
-
:
|
300
|
-
:
|
301
|
-
:
|
301
|
+
another_model: AssociatedModel.create!(
|
302
|
+
title: "foo bar",
|
303
|
+
author: "baz"
|
302
304
|
)
|
303
305
|
)
|
304
306
|
]
|
305
307
|
excluded = [
|
306
308
|
ModelWithAssociation.create!(
|
307
|
-
:
|
308
|
-
:
|
309
|
-
:
|
309
|
+
another_model: AssociatedModel.create!(
|
310
|
+
title: "foo",
|
311
|
+
author: "baz"
|
310
312
|
)
|
311
313
|
)
|
312
314
|
]
|
@@ -336,18 +338,18 @@ describe PgSearch do
|
|
336
338
|
include PgSearch
|
337
339
|
belongs_to :another_model, class_name: 'AssociatedModel'
|
338
340
|
|
339
|
-
pg_search_scope :with_associated, associated_against: {another_model: :number}
|
341
|
+
pg_search_scope :with_associated, associated_against: { another_model: :number }
|
340
342
|
end
|
341
343
|
end
|
342
344
|
|
343
345
|
it "should cast the columns to text" do
|
344
|
-
associated = AssociatedModel.create!(:
|
346
|
+
associated = AssociatedModel.create!(number: 123)
|
345
347
|
included = [
|
346
|
-
Model.create!(:
|
347
|
-
Model.create!(:
|
348
|
+
Model.create!(number: 123, another_model: associated),
|
349
|
+
Model.create!(number: 456, another_model: associated)
|
348
350
|
]
|
349
351
|
excluded = [
|
350
|
-
Model.create!(:
|
352
|
+
Model.create!(number: 123)
|
351
353
|
]
|
352
354
|
|
353
355
|
results = Model.with_associated('123')
|
@@ -365,7 +367,7 @@ describe PgSearch do
|
|
365
367
|
model do
|
366
368
|
has_many :children
|
367
369
|
include PgSearch
|
368
|
-
pg_search_scope :search_name, :
|
370
|
+
pg_search_scope :search_name, against: :name
|
369
371
|
end
|
370
372
|
end
|
371
373
|
|
@@ -381,8 +383,8 @@ describe PgSearch do
|
|
381
383
|
|
382
384
|
# https://github.com/Casecommons/pg_search/issues/14
|
383
385
|
it "supports queries with periods" do
|
384
|
-
included = Parent.create!(:
|
385
|
-
excluded = Parent.create!(:
|
386
|
+
included = Parent.create!(name: 'bar.foo')
|
387
|
+
excluded = Parent.create!(name: 'foo.bar')
|
386
388
|
|
387
389
|
results = Parent.search_name('bar.foo').includes(:children)
|
388
390
|
results.to_a
|
@@ -410,24 +412,24 @@ describe PgSearch do
|
|
410
412
|
include PgSearch
|
411
413
|
belongs_to :model_with_association
|
412
414
|
|
413
|
-
pg_search_scope :search_content, :
|
415
|
+
pg_search_scope :search_content, against: :content
|
414
416
|
end
|
415
417
|
end
|
416
418
|
|
417
419
|
it "should find records of the other model" do
|
418
|
-
included_associated_1 = AssociatedModel.create(:
|
419
|
-
included_associated_2 = AssociatedModel.create(:
|
420
|
-
excluded_associated_1 = AssociatedModel.create(:
|
421
|
-
excluded_associated_2 = AssociatedModel.create(:
|
420
|
+
included_associated_1 = AssociatedModel.create(content: "foo bar")
|
421
|
+
included_associated_2 = AssociatedModel.create(content: "foo baz")
|
422
|
+
excluded_associated_1 = AssociatedModel.create(content: "baz quux")
|
423
|
+
excluded_associated_2 = AssociatedModel.create(content: "baz bar")
|
422
424
|
|
423
425
|
included = [
|
424
|
-
ModelWithAssociation.create(:
|
425
|
-
ModelWithAssociation.create(:
|
426
|
+
ModelWithAssociation.create(associated_models: [included_associated_1]),
|
427
|
+
ModelWithAssociation.create(associated_models: [included_associated_2, excluded_associated_1])
|
426
428
|
]
|
427
429
|
|
428
430
|
excluded = [
|
429
|
-
ModelWithAssociation.create(:
|
430
|
-
ModelWithAssociation.create(:
|
431
|
+
ModelWithAssociation.create(associated_models: [excluded_associated_2]),
|
432
|
+
ModelWithAssociation.create(associated_models: [])
|
431
433
|
]
|
432
434
|
|
433
435
|
relation = AssociatedModel.search_content("foo")
|
@@ -454,7 +456,7 @@ describe PgSearch do
|
|
454
456
|
|
455
457
|
model do
|
456
458
|
include PgSearch
|
457
|
-
pg_search_scope :search, :
|
459
|
+
pg_search_scope :search, against: :title, using: %i[tsearch trigram]
|
458
460
|
end
|
459
461
|
end
|
460
462
|
|
@@ -464,13 +466,13 @@ describe PgSearch do
|
|
464
466
|
another_company = Company.create!
|
465
467
|
|
466
468
|
included = [
|
467
|
-
Position.create!(:
|
469
|
+
Position.create!(company_id: company.id, title: "teller 1")
|
468
470
|
]
|
469
471
|
|
470
472
|
excluded = [
|
471
|
-
Position.create!(:
|
472
|
-
Position.create!(:
|
473
|
-
Position.create!(:
|
473
|
+
Position.create!(company_id: nil, title: "teller 1"),
|
474
|
+
Position.create!(company_id: another_company.id, title: "teller 1"),
|
475
|
+
Position.create!(company_id: company.id, title: "penn 1")
|
474
476
|
]
|
475
477
|
|
476
478
|
results = company.positions.search('teller 1')
|
@@ -495,7 +497,7 @@ describe PgSearch do
|
|
495
497
|
|
496
498
|
model do
|
497
499
|
include PgSearch
|
498
|
-
pg_search_scope :search, :
|
500
|
+
pg_search_scope :search, against: :title, using: %i[tsearch trigram]
|
499
501
|
end
|
500
502
|
end
|
501
503
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe "pagination" do
|
@@ -9,7 +11,7 @@ describe "pagination" do
|
|
9
11
|
|
10
12
|
model do
|
11
13
|
include PgSearch
|
12
|
-
pg_search_scope :search_name, :
|
14
|
+
pg_search_scope :search_name, against: :name
|
13
15
|
|
14
16
|
def self.page(page_number)
|
15
17
|
offset = (page_number - 1) * 2
|
@@ -19,18 +21,18 @@ describe "pagination" do
|
|
19
21
|
end
|
20
22
|
|
21
23
|
it "is chainable before a search scope" do
|
22
|
-
better = PaginatedModel.create!(:
|
23
|
-
best = PaginatedModel.create!(:
|
24
|
-
good = PaginatedModel.create!(:
|
24
|
+
better = PaginatedModel.create!(name: "foo foo bar")
|
25
|
+
best = PaginatedModel.create!(name: "foo foo foo")
|
26
|
+
good = PaginatedModel.create!(name: "foo bar bar")
|
25
27
|
|
26
28
|
expect(PaginatedModel.page(1).search_name("foo")).to eq([best, better])
|
27
29
|
expect(PaginatedModel.page(2).search_name("foo")).to eq([good])
|
28
30
|
end
|
29
31
|
|
30
32
|
it "is chainable after a search scope" do
|
31
|
-
better = PaginatedModel.create!(:
|
32
|
-
best = PaginatedModel.create!(:
|
33
|
-
good = PaginatedModel.create!(:
|
33
|
+
better = PaginatedModel.create!(name: "foo foo bar")
|
34
|
+
best = PaginatedModel.create!(name: "foo foo foo")
|
35
|
+
good = PaginatedModel.create!(name: "foo bar bar")
|
34
36
|
|
35
37
|
expect(PaginatedModel.search_name("foo").page(1)).to eq([best, better])
|
36
38
|
expect(PaginatedModel.search_name("foo").page(2)).to eq([good])
|