pg_search 2.1.4 → 2.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -4
  3. data/.travis.yml +27 -25
  4. data/CHANGELOG.md +4 -0
  5. data/Gemfile +4 -4
  6. data/README.md +184 -151
  7. data/Rakefile +1 -5
  8. data/lib/pg_search.rb +1 -1
  9. data/lib/pg_search/configuration.rb +2 -2
  10. data/lib/pg_search/document.rb +3 -3
  11. data/lib/pg_search/features/dmetaphone.rb +1 -1
  12. data/lib/pg_search/features/feature.rb +1 -1
  13. data/lib/pg_search/migration/templates/create_pg_search_documents.rb.erb +1 -1
  14. data/lib/pg_search/multisearch.rb +1 -1
  15. data/lib/pg_search/multisearchable.rb +4 -4
  16. data/lib/pg_search/scope_options.rb +13 -28
  17. data/lib/pg_search/version.rb +1 -1
  18. data/pg_search.gemspec +1 -2
  19. data/spec/integration/associations_spec.rb +100 -100
  20. data/spec/integration/pagination_spec.rb +7 -7
  21. data/spec/integration/pg_search_spec.rb +225 -225
  22. data/spec/integration/single_table_inheritance_spec.rb +14 -14
  23. data/spec/lib/pg_search/configuration/association_spec.rb +5 -5
  24. data/spec/lib/pg_search/configuration/foreign_column_spec.rb +1 -1
  25. data/spec/lib/pg_search/features/dmetaphone_spec.rb +2 -2
  26. data/spec/lib/pg_search/features/trigram_spec.rb +1 -1
  27. data/spec/lib/pg_search/features/tsearch_spec.rb +12 -12
  28. data/spec/lib/pg_search/multisearch/rebuilder_spec.rb +10 -10
  29. data/spec/lib/pg_search/multisearch_spec.rb +5 -5
  30. data/spec/lib/pg_search/multisearchable_spec.rb +26 -26
  31. data/spec/lib/pg_search/normalizer_spec.rb +5 -5
  32. data/spec/lib/pg_search_spec.rb +30 -30
  33. data/spec/spec_helper.rb +1 -1
  34. data/spec/support/database.rb +12 -19
  35. metadata +4 -18
data/Rakefile CHANGED
@@ -11,8 +11,4 @@ RuboCop::RakeTask.new do |t|
11
11
  t.options = %w[--display-cop-names]
12
12
  end
13
13
 
14
- task :codeclimate do
15
- sh 'bin/codeclimate-test-reporter' if ENV['CODECLIMATE_REPO_TOKEN']
16
- end
17
-
18
- task :default => %w[spec codeclimate rubocop]
14
+ task default: %w[spec rubocop]
@@ -27,7 +27,7 @@ module PgSearch
27
27
  options_proc = if options.respond_to?(:call)
28
28
  options
29
29
  elsif options.respond_to?(:merge)
30
- ->(query) { { :query => query }.merge(options) }
30
+ ->(query) { { query: query }.merge(options) }
31
31
  else
32
32
  raise ArgumentError, 'pg_search_scope expects a Hash or Proc'
33
33
  end
@@ -80,7 +80,7 @@ module PgSearch
80
80
  attr_reader :options
81
81
 
82
82
  def default_options
83
- { :using => :tsearch }
83
+ { using: :tsearch }
84
84
  end
85
85
 
86
86
  VALID_KEYS = %w[
@@ -88,7 +88,7 @@ module PgSearch
88
88
  ].map(&:to_sym)
89
89
 
90
90
  VALID_VALUES = {
91
- :ignoring => [:accents]
91
+ ignoring: [:accents]
92
92
  }.freeze
93
93
 
94
94
  def assert_valid_options(options)
@@ -7,7 +7,7 @@ module PgSearch
7
7
  include PgSearch
8
8
 
9
9
  self.table_name = 'pg_search_documents'
10
- belongs_to :searchable, :polymorphic => true
10
+ belongs_to :searchable, polymorphic: true
11
11
 
12
12
  # The logger might not have loaded yet.
13
13
  # https://github.com/Casecommons/pg_search/issues/26
@@ -19,10 +19,10 @@ module PgSearch
19
19
  options = if PgSearch.multisearch_options.respond_to?(:call)
20
20
  PgSearch.multisearch_options.call(*args)
21
21
  else
22
- { :query => args.first }.merge(PgSearch.multisearch_options)
22
+ { query: args.first }.merge(PgSearch.multisearch_options)
23
23
  end
24
24
 
25
- { :against => :content }.merge(options)
25
+ { against: :content }.merge(options)
26
26
  }
27
27
  end
28
28
  end
@@ -5,7 +5,7 @@ module PgSearch
5
5
  class DMetaphone
6
6
  def initialize(query, options, columns, model, normalizer)
7
7
  dmetaphone_normalizer = Normalizer.new(normalizer)
8
- options = (options || {}).merge(:dictionary => 'simple')
8
+ options = (options || {}).merge(dictionary: 'simple')
9
9
  @tsearch = TSearch.new(query, options, columns, model, dmetaphone_normalizer)
10
10
  end
11
11
 
@@ -10,7 +10,7 @@ module PgSearch
10
10
  %i[only sort_only]
11
11
  end
12
12
 
13
- delegate :connection, :quoted_table_name, :to => :'@model'
13
+ delegate :connection, :quoted_table_name, to: :'@model'
14
14
 
15
15
  def initialize(query, options, all_columns, model, normalizer)
16
16
  @query = query
@@ -3,7 +3,7 @@ class CreatePgSearchDocuments < ActiveRecord::Migration<%= migration_version %>
3
3
  say_with_time("Creating table for pg_search multisearch") do
4
4
  create_table :pg_search_documents do |t|
5
5
  t.text :content
6
- t.belongs_to :searchable, :polymorphic => true, :index => true
6
+ t.belongs_to :searchable, polymorphic: true, index: true
7
7
  t.timestamps null: false
8
8
  end
9
9
  end
@@ -7,7 +7,7 @@ module PgSearch
7
7
  class << self
8
8
  def rebuild(model, clean_up = true)
9
9
  model.transaction do
10
- PgSearch::Document.where(:searchable_type => model.base_class.name).delete_all if clean_up
10
+ PgSearch::Document.where(searchable_type: model.base_class.name).delete_all if clean_up
11
11
  Rebuilder.new(model).rebuild
12
12
  end
13
13
  end
@@ -7,12 +7,12 @@ module PgSearch
7
7
  def self.included(mod)
8
8
  mod.class_eval do
9
9
  has_one :pg_search_document,
10
- :as => :searchable,
11
- :class_name => "PgSearch::Document",
12
- :dependent => :delete
10
+ as: :searchable,
11
+ class_name: "PgSearch::Document",
12
+ dependent: :delete
13
13
 
14
14
  after_save :update_pg_search_document,
15
- :if => -> { PgSearch.multisearch_enabled? }
15
+ if: -> { PgSearch.multisearch_enabled? }
16
16
  end
17
17
  end
18
18
 
@@ -69,7 +69,7 @@ module PgSearch
69
69
  def pg_search_rank_table_alias(include_counter = false)
70
70
  components = [arel_table.name]
71
71
  if include_counter
72
- count = pg_search_scope_application_count_plus_plus
72
+ count = increment_counter
73
73
  components << count if count > 0
74
74
  end
75
75
 
@@ -78,22 +78,16 @@ module PgSearch
78
78
 
79
79
  private
80
80
 
81
- attr_writer :pg_search_scope_application_count
82
-
83
- def pg_search_scope_application_count
84
- @pg_search_scope_application_count ||= 0
85
- end
86
-
87
- def pg_search_scope_application_count_plus_plus
88
- count = pg_search_scope_application_count
89
- self.pg_search_scope_application_count = pg_search_scope_application_count + 1
90
- count
81
+ def increment_counter
82
+ @counter ||= 0
83
+ ensure
84
+ @counter += 1
91
85
  end
92
86
  end
93
87
 
94
88
  private
95
89
 
96
- delegate :connection, :quoted_table_name, :to => :model
90
+ delegate :connection, :quoted_table_name, to: :model
97
91
 
98
92
  def subquery
99
93
  model
@@ -107,19 +101,10 @@ module PgSearch
107
101
  end
108
102
 
109
103
  def conditions
110
- conditions = config.features.reject do |_feature_name, feature_options|
111
- feature_options && feature_options[:sort_only]
112
- end
113
-
114
- conditions.map! do |feature_name, _feature_options|
115
- feature_for(feature_name).conditions
116
- end
117
-
118
- conditions = conditions.inject do |accumulator, expression|
119
- Arel::Nodes::Or.new(accumulator, expression)
120
- end
121
-
122
- conditions.to_sql
104
+ config.features
105
+ .reject { |_feature_name, feature_options| feature_options && feature_options[:sort_only] }
106
+ .map { |feature_name, _feature_options| feature_for(feature_name).conditions }
107
+ .inject { |accumulator, expression| Arel::Nodes::Or.new(accumulator, expression) }
123
108
  end
124
109
 
125
110
  def order_within_rank
@@ -139,9 +124,9 @@ module PgSearch
139
124
  end
140
125
 
141
126
  FEATURE_CLASSES = {
142
- :dmetaphone => Features::DMetaphone,
143
- :tsearch => Features::TSearch,
144
- :trigram => Features::Trigram
127
+ dmetaphone: Features::DMetaphone,
128
+ tsearch: Features::TSearch,
129
+ trigram: Features::Trigram
145
130
  }.freeze
146
131
 
147
132
  def feature_for(feature_name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgSearch
4
- VERSION = '2.1.4'
4
+ VERSION = '2.1.5'
5
5
  end
@@ -21,7 +21,6 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'activerecord', '>= 4.2'
22
22
  s.add_dependency 'activesupport', '>= 4.2'
23
23
 
24
- s.add_development_dependency 'codeclimate-test-reporter'
25
24
  s.add_development_dependency 'pry'
26
25
  s.add_development_dependency 'rake'
27
26
  s.add_development_dependency 'rspec', '>= 3.3'
@@ -29,5 +28,5 @@ Gem::Specification.new do |s|
29
28
  s.add_development_dependency 'simplecov'
30
29
  s.add_development_dependency 'with_model', '>= 1.2'
31
30
 
32
- s.required_ruby_version = '>= 2.3'
31
+ s.required_ruby_version = '>= 2.4'
33
32
  end
@@ -14,25 +14,25 @@ describe PgSearch do
14
14
  with_model :ModelWithoutAgainst do
15
15
  table do |t|
16
16
  t.string "title"
17
- t.belongs_to :another_model, :index => false
17
+ t.belongs_to :another_model, index: false
18
18
  end
19
19
 
20
20
  model do
21
21
  include PgSearch
22
- belongs_to :another_model, :class_name => 'AssociatedModel'
22
+ belongs_to :another_model, class_name: 'AssociatedModel'
23
23
 
24
- pg_search_scope :with_another, :associated_against => { :another_model => :title }
24
+ pg_search_scope :with_another, associated_against: { another_model: :title }
25
25
  end
26
26
  end
27
27
 
28
28
  it "returns rows that match the query in the columns of the associated model only" do
29
- associated = AssociatedModel.create!(:title => 'abcdef')
29
+ associated = AssociatedModel.create!(title: 'abcdef')
30
30
  included = [
31
- ModelWithoutAgainst.create!(:title => 'abcdef', :another_model => associated),
32
- ModelWithoutAgainst.create!(:title => 'ghijkl', :another_model => associated)
31
+ ModelWithoutAgainst.create!(title: 'abcdef', another_model: associated),
32
+ ModelWithoutAgainst.create!(title: 'ghijkl', another_model: associated)
33
33
  ]
34
34
  excluded = [
35
- ModelWithoutAgainst.create!(:title => 'abcdef')
35
+ ModelWithoutAgainst.create!(title: 'abcdef')
36
36
  ]
37
37
 
38
38
  results = ModelWithoutAgainst.with_another('abcdef')
@@ -56,20 +56,20 @@ describe PgSearch do
56
56
 
57
57
  model do
58
58
  include PgSearch
59
- belongs_to :another_model, :class_name => 'AssociatedModel'
59
+ belongs_to :another_model, class_name: 'AssociatedModel'
60
60
 
61
- pg_search_scope :with_associated, :against => :title, :associated_against => { :another_model => :title }
61
+ pg_search_scope :with_associated, against: :title, associated_against: { another_model: :title }
62
62
  end
63
63
  end
64
64
 
65
65
  it "returns rows that match the query in either its own columns or the columns of the associated model" do
66
- associated = AssociatedModel.create!(:title => 'abcdef')
66
+ associated = AssociatedModel.create!(title: 'abcdef')
67
67
  included = [
68
- ModelWithBelongsTo.create!(:title => 'ghijkl', :another_model => associated),
69
- ModelWithBelongsTo.create!(:title => 'abcdef')
68
+ ModelWithBelongsTo.create!(title: 'ghijkl', another_model: associated),
69
+ ModelWithBelongsTo.create!(title: 'abcdef')
70
70
  ]
71
- excluded = ModelWithBelongsTo.create!(:title => 'mnopqr',
72
- :another_model => AssociatedModel.create!(:title => 'stuvwx'))
71
+ excluded = ModelWithBelongsTo.create!(title: 'mnopqr',
72
+ another_model: AssociatedModel.create!(title: 'stuvwx'))
73
73
 
74
74
  results = ModelWithBelongsTo.with_associated('abcdef')
75
75
  expect(results.map(&:title)).to match_array(included.map(&:title))
@@ -92,26 +92,26 @@ describe PgSearch do
92
92
 
93
93
  model do
94
94
  include PgSearch
95
- has_many :other_models, :class_name => 'AssociatedModelWithHasMany', :foreign_key => 'ModelWithHasMany_id'
95
+ has_many :other_models, class_name: 'AssociatedModelWithHasMany', foreign_key: 'ModelWithHasMany_id'
96
96
 
97
- pg_search_scope :with_associated, :against => [:title], :associated_against => { :other_models => :title }
97
+ pg_search_scope :with_associated, against: [:title], associated_against: { other_models: :title }
98
98
  end
99
99
  end
100
100
 
101
101
  it "returns rows that match the query in either its own columns or the columns of the associated model" do
102
102
  included = [
103
- ModelWithHasMany.create!(:title => 'abcdef', :other_models => [
104
- AssociatedModelWithHasMany.create!(:title => 'foo'),
105
- AssociatedModelWithHasMany.create!(:title => 'bar')
103
+ ModelWithHasMany.create!(title: 'abcdef', other_models: [
104
+ AssociatedModelWithHasMany.create!(title: 'foo'),
105
+ AssociatedModelWithHasMany.create!(title: 'bar')
106
106
  ]),
107
- ModelWithHasMany.create!(:title => 'ghijkl', :other_models => [
108
- AssociatedModelWithHasMany.create!(:title => 'foo bar'),
109
- AssociatedModelWithHasMany.create!(:title => 'mnopqr')
107
+ ModelWithHasMany.create!(title: 'ghijkl', other_models: [
108
+ AssociatedModelWithHasMany.create!(title: 'foo bar'),
109
+ AssociatedModelWithHasMany.create!(title: 'mnopqr')
110
110
  ]),
111
- ModelWithHasMany.create!(:title => 'foo bar')
111
+ ModelWithHasMany.create!(title: 'foo bar')
112
112
  ]
113
- excluded = ModelWithHasMany.create!(:title => 'stuvwx', :other_models => [
114
- AssociatedModelWithHasMany.create!(:title => 'abcdef')
113
+ excluded = ModelWithHasMany.create!(title: 'stuvwx', other_models: [
114
+ AssociatedModelWithHasMany.create!(title: 'abcdef')
115
115
  ])
116
116
 
117
117
  results = ModelWithHasMany.with_associated('foo bar')
@@ -120,14 +120,14 @@ describe PgSearch do
120
120
  end
121
121
 
122
122
  it "uses an unscoped relation of the associated model" do
123
- excluded = ModelWithHasMany.create!(:title => 'abcdef', :other_models => [
124
- AssociatedModelWithHasMany.create!(:title => 'abcdef')
123
+ excluded = ModelWithHasMany.create!(title: 'abcdef', other_models: [
124
+ AssociatedModelWithHasMany.create!(title: 'abcdef')
125
125
  ])
126
126
 
127
127
  included = [
128
- ModelWithHasMany.create!(:title => 'abcdef', :other_models => [
129
- AssociatedModelWithHasMany.create!(:title => 'foo'),
130
- AssociatedModelWithHasMany.create!(:title => 'bar')
128
+ ModelWithHasMany.create!(title: 'abcdef', other_models: [
129
+ AssociatedModelWithHasMany.create!(title: 'foo'),
130
+ AssociatedModelWithHasMany.create!(title: 'bar')
131
131
  ])
132
132
  ]
133
133
 
@@ -166,39 +166,39 @@ describe PgSearch do
166
166
  include PgSearch
167
167
 
168
168
  has_many :models_of_first_type,
169
- :class_name => 'FirstAssociatedModel',
170
- :foreign_key => 'ModelWithManyAssociations_id'
169
+ class_name: 'FirstAssociatedModel',
170
+ foreign_key: 'ModelWithManyAssociations_id'
171
171
 
172
172
  belongs_to :model_of_second_type,
173
- :class_name => 'SecondAssociatedModel'
173
+ class_name: 'SecondAssociatedModel'
174
174
 
175
175
  pg_search_scope :with_associated,
176
- :against => :title,
177
- :associated_against => { :models_of_first_type => :title, :model_of_second_type => :title }
176
+ against: :title,
177
+ associated_against: { models_of_first_type: :title, model_of_second_type: :title }
178
178
  end
179
179
  end
180
180
 
181
181
  it "returns rows that match the query in either its own columns or the columns of the associated model" do
182
- matching_second = SecondAssociatedModel.create!(:title => "foo bar")
183
- unmatching_second = SecondAssociatedModel.create!(:title => "uiop")
182
+ matching_second = SecondAssociatedModel.create!(title: "foo bar")
183
+ unmatching_second = SecondAssociatedModel.create!(title: "uiop")
184
184
 
185
185
  included = [
186
- ModelWithManyAssociations.create!(:title => 'abcdef', :models_of_first_type => [
187
- FirstAssociatedModel.create!(:title => 'foo'),
188
- FirstAssociatedModel.create!(:title => 'bar')
186
+ ModelWithManyAssociations.create!(title: 'abcdef', models_of_first_type: [
187
+ FirstAssociatedModel.create!(title: 'foo'),
188
+ FirstAssociatedModel.create!(title: 'bar')
189
189
  ]),
190
- ModelWithManyAssociations.create!(:title => 'ghijkl', :models_of_first_type => [
191
- FirstAssociatedModel.create!(:title => 'foo bar'),
192
- FirstAssociatedModel.create!(:title => 'mnopqr')
190
+ ModelWithManyAssociations.create!(title: 'ghijkl', models_of_first_type: [
191
+ FirstAssociatedModel.create!(title: 'foo bar'),
192
+ FirstAssociatedModel.create!(title: 'mnopqr')
193
193
  ]),
194
- ModelWithManyAssociations.create!(:title => 'foo bar'),
195
- ModelWithManyAssociations.create!(:title => 'qwerty', :model_of_second_type => matching_second)
194
+ ModelWithManyAssociations.create!(title: 'foo bar'),
195
+ ModelWithManyAssociations.create!(title: 'qwerty', model_of_second_type: matching_second)
196
196
  ]
197
197
  excluded = [
198
- ModelWithManyAssociations.create!(:title => 'stuvwx', :models_of_first_type => [
199
- FirstAssociatedModel.create!(:title => 'abcdef')
198
+ ModelWithManyAssociations.create!(title: 'stuvwx', models_of_first_type: [
199
+ FirstAssociatedModel.create!(title: 'abcdef')
200
200
  ]),
201
- ModelWithManyAssociations.create!(:title => 'qwerty', :model_of_second_type => unmatching_second)
201
+ ModelWithManyAssociations.create!(title: 'qwerty', model_of_second_type: unmatching_second)
202
202
  ]
203
203
 
204
204
  results = ModelWithManyAssociations.with_associated('foo bar')
@@ -225,39 +225,39 @@ describe PgSearch do
225
225
  include PgSearch
226
226
 
227
227
  has_many :things,
228
- :class_name => 'DoublyAssociatedModel',
229
- :foreign_key => 'ModelWithDoubleAssociation_id'
228
+ class_name: 'DoublyAssociatedModel',
229
+ foreign_key: 'ModelWithDoubleAssociation_id'
230
230
 
231
231
  has_many :thingamabobs,
232
- :class_name => 'DoublyAssociatedModel',
233
- :foreign_key => 'ModelWithDoubleAssociation_again_id'
232
+ class_name: 'DoublyAssociatedModel',
233
+ foreign_key: 'ModelWithDoubleAssociation_again_id'
234
234
 
235
- pg_search_scope :with_associated, :against => :title,
236
- :associated_against => { :things => :title, :thingamabobs => :title }
235
+ pg_search_scope :with_associated, against: :title,
236
+ associated_against: { things: :title, thingamabobs: :title }
237
237
  end
238
238
  end
239
239
 
240
240
  it "returns rows that match the query in either its own columns or the columns of the associated model" do
241
241
  included = [
242
- ModelWithDoubleAssociation.create!(:title => 'abcdef', :things => [
243
- DoublyAssociatedModel.create!(:title => 'foo'),
244
- DoublyAssociatedModel.create!(:title => 'bar')
242
+ ModelWithDoubleAssociation.create!(title: 'abcdef', things: [
243
+ DoublyAssociatedModel.create!(title: 'foo'),
244
+ DoublyAssociatedModel.create!(title: 'bar')
245
245
  ]),
246
- ModelWithDoubleAssociation.create!(:title => 'ghijkl', :things => [
247
- DoublyAssociatedModel.create!(:title => 'foo bar'),
248
- DoublyAssociatedModel.create!(:title => 'mnopqr')
246
+ ModelWithDoubleAssociation.create!(title: 'ghijkl', things: [
247
+ DoublyAssociatedModel.create!(title: 'foo bar'),
248
+ DoublyAssociatedModel.create!(title: 'mnopqr')
249
249
  ]),
250
- ModelWithDoubleAssociation.create!(:title => 'foo bar'),
251
- ModelWithDoubleAssociation.create!(:title => 'qwerty', :thingamabobs => [
252
- DoublyAssociatedModel.create!(:title => "foo bar")
250
+ ModelWithDoubleAssociation.create!(title: 'foo bar'),
251
+ ModelWithDoubleAssociation.create!(title: 'qwerty', thingamabobs: [
252
+ DoublyAssociatedModel.create!(title: "foo bar")
253
253
  ])
254
254
  ]
255
255
  excluded = [
256
- ModelWithDoubleAssociation.create!(:title => 'stuvwx', :things => [
257
- DoublyAssociatedModel.create!(:title => 'abcdef')
256
+ ModelWithDoubleAssociation.create!(title: 'stuvwx', things: [
257
+ DoublyAssociatedModel.create!(title: 'abcdef')
258
258
  ]),
259
- ModelWithDoubleAssociation.create!(:title => 'qwerty', :thingamabobs => [
260
- DoublyAssociatedModel.create!(:title => "uiop")
259
+ ModelWithDoubleAssociation.create!(title: 'qwerty', thingamabobs: [
260
+ DoublyAssociatedModel.create!(title: "uiop")
261
261
  ])
262
262
  ]
263
263
 
@@ -283,32 +283,32 @@ describe PgSearch do
283
283
 
284
284
  model do
285
285
  include PgSearch
286
- belongs_to :another_model, :class_name => 'AssociatedModel'
286
+ belongs_to :another_model, class_name: 'AssociatedModel'
287
287
 
288
- pg_search_scope :with_associated, :associated_against => { :another_model => %i[title author] }
288
+ pg_search_scope :with_associated, associated_against: { another_model: %i[title author] }
289
289
  end
290
290
  end
291
291
 
292
292
  it "should only do one join" do
293
293
  included = [
294
294
  ModelWithAssociation.create!(
295
- :another_model => AssociatedModel.create!(
296
- :title => "foo",
297
- :author => "bar"
295
+ another_model: AssociatedModel.create!(
296
+ title: "foo",
297
+ author: "bar"
298
298
  )
299
299
  ),
300
300
  ModelWithAssociation.create!(
301
- :another_model => AssociatedModel.create!(
302
- :title => "foo bar",
303
- :author => "baz"
301
+ another_model: AssociatedModel.create!(
302
+ title: "foo bar",
303
+ author: "baz"
304
304
  )
305
305
  )
306
306
  ]
307
307
  excluded = [
308
308
  ModelWithAssociation.create!(
309
- :another_model => AssociatedModel.create!(
310
- :title => "foo",
311
- :author => "baz"
309
+ another_model: AssociatedModel.create!(
310
+ title: "foo",
311
+ author: "baz"
312
312
  )
313
313
  )
314
314
  ]
@@ -343,13 +343,13 @@ describe PgSearch do
343
343
  end
344
344
 
345
345
  it "should cast the columns to text" do
346
- associated = AssociatedModel.create!(:number => 123)
346
+ associated = AssociatedModel.create!(number: 123)
347
347
  included = [
348
- Model.create!(:number => 123, :another_model => associated),
349
- Model.create!(:number => 456, :another_model => associated)
348
+ Model.create!(number: 123, another_model: associated),
349
+ Model.create!(number: 456, another_model: associated)
350
350
  ]
351
351
  excluded = [
352
- Model.create!(:number => 123)
352
+ Model.create!(number: 123)
353
353
  ]
354
354
 
355
355
  results = Model.with_associated('123')
@@ -367,7 +367,7 @@ describe PgSearch do
367
367
  model do
368
368
  has_many :children
369
369
  include PgSearch
370
- pg_search_scope :search_name, :against => :name
370
+ pg_search_scope :search_name, against: :name
371
371
  end
372
372
  end
373
373
 
@@ -383,8 +383,8 @@ describe PgSearch do
383
383
 
384
384
  # https://github.com/Casecommons/pg_search/issues/14
385
385
  it "supports queries with periods" do
386
- included = Parent.create!(:name => 'bar.foo')
387
- excluded = Parent.create!(:name => 'foo.bar')
386
+ included = Parent.create!(name: 'bar.foo')
387
+ excluded = Parent.create!(name: 'foo.bar')
388
388
 
389
389
  results = Parent.search_name('bar.foo').includes(:children)
390
390
  results.to_a
@@ -412,24 +412,24 @@ describe PgSearch do
412
412
  include PgSearch
413
413
  belongs_to :model_with_association
414
414
 
415
- pg_search_scope :search_content, :against => :content
415
+ pg_search_scope :search_content, against: :content
416
416
  end
417
417
  end
418
418
 
419
419
  it "should find records of the other model" do
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")
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")
424
424
 
425
425
  included = [
426
- ModelWithAssociation.create(:associated_models => [included_associated_1]),
427
- ModelWithAssociation.create(:associated_models => [included_associated_2, excluded_associated_1])
426
+ ModelWithAssociation.create(associated_models: [included_associated_1]),
427
+ ModelWithAssociation.create(associated_models: [included_associated_2, excluded_associated_1])
428
428
  ]
429
429
 
430
430
  excluded = [
431
- ModelWithAssociation.create(:associated_models => [excluded_associated_2]),
432
- ModelWithAssociation.create(:associated_models => [])
431
+ ModelWithAssociation.create(associated_models: [excluded_associated_2]),
432
+ ModelWithAssociation.create(associated_models: [])
433
433
  ]
434
434
 
435
435
  relation = AssociatedModel.search_content("foo")
@@ -456,7 +456,7 @@ describe PgSearch do
456
456
 
457
457
  model do
458
458
  include PgSearch
459
- pg_search_scope :search, :against => :title, :using => %i[tsearch trigram]
459
+ pg_search_scope :search, against: :title, using: %i[tsearch trigram]
460
460
  end
461
461
  end
462
462
 
@@ -466,13 +466,13 @@ describe PgSearch do
466
466
  another_company = Company.create!
467
467
 
468
468
  included = [
469
- Position.create!(:company_id => company.id, :title => "teller 1")
469
+ Position.create!(company_id: company.id, title: "teller 1")
470
470
  ]
471
471
 
472
472
  excluded = [
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")
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")
476
476
  ]
477
477
 
478
478
  results = company.positions.search('teller 1')
@@ -497,7 +497,7 @@ describe PgSearch do
497
497
 
498
498
  model do
499
499
  include PgSearch
500
- pg_search_scope :search, :against => :title, :using => %i[tsearch trigram]
500
+ pg_search_scope :search, against: :title, using: %i[tsearch trigram]
501
501
  end
502
502
  end
503
503