pg_search 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.rubocop.yml +5 -0
 - data/.travis.yml +10 -6
 - data/CHANGELOG.md +4 -0
 - data/lib/pg_search.rb +6 -7
 - data/lib/pg_search/configuration.rb +1 -3
 - data/lib/pg_search/multisearch/rebuilder.rb +2 -6
 - data/lib/pg_search/scope_options.rb +1 -1
 - data/lib/pg_search/version.rb +1 -1
 - data/pg_search.gemspec +3 -3
 - data/spec/integration/associations_spec.rb +1 -1
 - data/spec/lib/pg_search/multisearch/rebuilder_spec.rb +4 -4
 - data/spec/lib/pg_search_spec.rb +24 -3
 - data/spec/support/database.rb +2 -2
 - metadata +14 -14
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 39a86d998120bf6ec9643f8f8b549b08956576ff
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: fd3a0e7c1aea025553e4c1747d009a9911628d37
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 84aa3f0816a2aca1523b9bd418abb4445b2290eb5a3177870e43a52e1ca341271e9211042496198b8e2d9ba7c39c6b53afd2f10bc272544478976bafde763265
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: e4657a3efc304b264cb0640c1755be9f9cbbc01afb1804f5625dfea24498f5ab21b1e707801cf3c22df63e462bb7add5e737060a6f9b67ddbfbae600d53a3a5c
         
     | 
    
        data/.rubocop.yml
    CHANGED
    
    
    
        data/.travis.yml
    CHANGED
    
    | 
         @@ -6,13 +6,14 @@ rvm: 
     | 
|
| 
       6 
6 
     | 
    
         
             
              - "2.3.4"
         
     | 
| 
       7 
7 
     | 
    
         
             
              - "2.2.7"
         
     | 
| 
       8 
8 
     | 
    
         
             
              - "2.1.10"
         
     | 
| 
       9 
     | 
    
         
            -
              - jruby-9.1. 
     | 
| 
      
 9 
     | 
    
         
            +
              - jruby-9.1.14.0
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
            env:
         
     | 
| 
       12 
12 
     | 
    
         
             
              - ACTIVE_RECORD_BRANCH="master"
         
     | 
| 
       13 
13 
     | 
    
         
             
              - ACTIVE_RECORD_BRANCH="5-1-stable"
         
     | 
| 
       14 
14 
     | 
    
         
             
              - ACTIVE_RECORD_BRANCH="5-0-stable"
         
     | 
| 
       15 
15 
     | 
    
         
             
              - ACTIVE_RECORD_BRANCH="4-2-stable"
         
     | 
| 
      
 16 
     | 
    
         
            +
              - ACTIVE_RECORD_VERSION="~> 5.2.0.beta2"
         
     | 
| 
       16 
17 
     | 
    
         
             
              - ACTIVE_RECORD_VERSION="~> 5.1.0"
         
     | 
| 
       17 
18 
     | 
    
         
             
              - ACTIVE_RECORD_VERSION="~> 5.0.0"
         
     | 
| 
       18 
19 
     | 
    
         
             
              - ACTIVE_RECORD_VERSION="~> 4.2.9"
         
     | 
| 
         @@ -23,6 +24,7 @@ matrix: 
     | 
|
| 
       23 
24 
     | 
    
         
             
                - env: ACTIVE_RECORD_BRANCH="5-1-stable"
         
     | 
| 
       24 
25 
     | 
    
         
             
                - env: ACTIVE_RECORD_BRANCH="5-0-stable"
         
     | 
| 
       25 
26 
     | 
    
         
             
                - env: ACTIVE_RECORD_BRANCH="4-2-stable"
         
     | 
| 
      
 27 
     | 
    
         
            +
                - rvm: jruby-9.1.14.0
         
     | 
| 
       26 
28 
     | 
    
         
             
              exclude:
         
     | 
| 
       27 
29 
     | 
    
         
             
                - rvm: "2.1.10"
         
     | 
| 
       28 
30 
     | 
    
         
             
                  env: ACTIVE_RECORD_BRANCH="master"
         
     | 
| 
         @@ -34,15 +36,17 @@ matrix: 
     | 
|
| 
       34 
36 
     | 
    
         
             
                  env: ACTIVE_RECORD_VERSION="~> 5.1.0"
         
     | 
| 
       35 
37 
     | 
    
         
             
                - rvm: "2.1.10"
         
     | 
| 
       36 
38 
     | 
    
         
             
                  env: ACTIVE_RECORD_VERSION="~> 5.0.0"
         
     | 
| 
       37 
     | 
    
         
            -
                - rvm: jruby-9.1. 
     | 
| 
      
 39 
     | 
    
         
            +
                - rvm: jruby-9.1.14.0
         
     | 
| 
       38 
40 
     | 
    
         
             
                  env: ACTIVE_RECORD_BRANCH="master"
         
     | 
| 
       39 
     | 
    
         
            -
                - rvm: jruby-9.1. 
     | 
| 
      
 41 
     | 
    
         
            +
                - rvm: jruby-9.1.14.0
         
     | 
| 
       40 
42 
     | 
    
         
             
                  env: ACTIVE_RECORD_BRANCH="5-1-stable"
         
     | 
| 
       41 
     | 
    
         
            -
                - rvm: jruby-9.1. 
     | 
| 
      
 43 
     | 
    
         
            +
                - rvm: jruby-9.1.14.0
         
     | 
| 
       42 
44 
     | 
    
         
             
                  env: ACTIVE_RECORD_BRANCH="5-0-stable"
         
     | 
| 
       43 
     | 
    
         
            -
                - rvm: jruby-9.1. 
     | 
| 
      
 45 
     | 
    
         
            +
                - rvm: jruby-9.1.14.0
         
     | 
| 
      
 46 
     | 
    
         
            +
                  env: ACTIVE_RECORD_VERSION="~> 5.2.0.beta2"
         
     | 
| 
      
 47 
     | 
    
         
            +
                - rvm: jruby-9.1.14.0
         
     | 
| 
       44 
48 
     | 
    
         
             
                  env: ACTIVE_RECORD_VERSION="~> 5.1.0"
         
     | 
| 
       45 
     | 
    
         
            -
                - rvm: jruby-9.1. 
     | 
| 
      
 49 
     | 
    
         
            +
                - rvm: jruby-9.1.14.0
         
     | 
| 
       46 
50 
     | 
    
         
             
                  env: ACTIVE_RECORD_VERSION="~> 5.0.0"
         
     | 
| 
       47 
51 
     | 
    
         | 
| 
       48 
52 
     | 
    
         
             
            before_script:
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/lib/pg_search.rb
    CHANGED
    
    | 
         @@ -25,9 +25,7 @@ module PgSearch 
     | 
|
| 
       25 
25 
     | 
    
         
             
                  options_proc = if options.respond_to?(:call)
         
     | 
| 
       26 
26 
     | 
    
         
             
                                   options
         
     | 
| 
       27 
27 
     | 
    
         
             
                                 else
         
     | 
| 
       28 
     | 
    
         
            -
                                   unless options.respond_to?(:merge)
         
     | 
| 
       29 
     | 
    
         
            -
                                     raise ArgumentError, "pg_search_scope expects a Hash or Proc"
         
     | 
| 
       30 
     | 
    
         
            -
                                   end
         
     | 
| 
      
 28 
     | 
    
         
            +
                                   raise ArgumentError, "pg_search_scope expects a Hash or Proc" unless options.respond_to?(:merge)
         
     | 
| 
       31 
29 
     | 
    
         
             
                                   ->(query) { {:query => query}.merge(options) }
         
     | 
| 
       32 
30 
     | 
    
         
             
                                 end
         
     | 
| 
       33 
31 
     | 
    
         | 
| 
         @@ -39,7 +37,7 @@ module PgSearch 
     | 
|
| 
       39 
37 
     | 
    
         
             
                end
         
     | 
| 
       40 
38 
     | 
    
         | 
| 
       41 
39 
     | 
    
         
             
                def multisearchable(options = {})
         
     | 
| 
       42 
     | 
    
         
            -
                  include PgSearch::Multisearchable
         
     | 
| 
      
 40 
     | 
    
         
            +
                  include PgSearch::Multisearchable # rubocop:disable Style/MixinUsage
         
     | 
| 
       43 
41 
     | 
    
         
             
                  class_attribute :pg_search_multisearchable_options
         
     | 
| 
       44 
42 
     | 
    
         
             
                  self.pg_search_multisearchable_options = options
         
     | 
| 
       45 
43 
     | 
    
         
             
                end
         
     | 
| 
         @@ -92,14 +90,15 @@ module PgSearch 
     | 
|
| 
       92 
90 
     | 
    
         | 
| 
       93 
91 
     | 
    
         
             
              class PgSearchRankNotSelected < StandardError
         
     | 
| 
       94 
92 
     | 
    
         
             
                def message
         
     | 
| 
       95 
     | 
    
         
            -
                  "You must chain .with_pg_search_rank after the pg_search_scope  
     | 
| 
      
 93 
     | 
    
         
            +
                  "You must chain .with_pg_search_rank after the pg_search_scope " \
         
     | 
| 
      
 94 
     | 
    
         
            +
                  "to access the pg_search_rank attribute on returned records"
         
     | 
| 
       96 
95 
     | 
    
         
             
                end
         
     | 
| 
       97 
96 
     | 
    
         
             
              end
         
     | 
| 
       98 
97 
     | 
    
         | 
| 
       99 
98 
     | 
    
         
             
              class PgSearchHighlightNotSelected < StandardError
         
     | 
| 
       100 
     | 
    
         
            -
                # rubocop:disable Metrics/LineLength
         
     | 
| 
       101 
99 
     | 
    
         
             
                def message
         
     | 
| 
       102 
     | 
    
         
            -
                  "You must chain .with_pg_search_highlight after the pg_search_scope  
     | 
| 
      
 100 
     | 
    
         
            +
                  "You must chain .with_pg_search_highlight after the pg_search_scope " \
         
     | 
| 
      
 101 
     | 
    
         
            +
                  "to access the pg_search_highlight attribute on returned records"
         
     | 
| 
       103 
102 
     | 
    
         
             
                end
         
     | 
| 
       104 
103 
     | 
    
         
             
              end
         
     | 
| 
       105 
104 
     | 
    
         
             
            end
         
     | 
| 
         @@ -96,9 +96,7 @@ module PgSearch 
     | 
|
| 
       96 
96 
     | 
    
         | 
| 
       97 
97 
     | 
    
         
             
                  VALID_VALUES.each do |key, values_for_key|
         
     | 
| 
       98 
98 
     | 
    
         
             
                    Array(options[key]).each do |value|
         
     | 
| 
       99 
     | 
    
         
            -
                      unless values_for_key.include?(value)
         
     | 
| 
       100 
     | 
    
         
            -
                        raise ArgumentError, ":#{key} cannot accept #{value}"
         
     | 
| 
       101 
     | 
    
         
            -
                      end
         
     | 
| 
      
 99 
     | 
    
         
            +
                      raise ArgumentError, ":#{key} cannot accept #{value}" unless values_for_key.include?(value)
         
     | 
| 
       102 
100 
     | 
    
         
             
                    end
         
     | 
| 
       103 
101 
     | 
    
         
             
                  end
         
     | 
| 
       104 
102 
     | 
    
         
             
                end
         
     | 
| 
         @@ -2,9 +2,7 @@ module PgSearch 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Multisearch
         
     | 
| 
       3 
3 
     | 
    
         
             
                class Rebuilder
         
     | 
| 
       4 
4 
     | 
    
         
             
                  def initialize(model, time_source = Time.method(:now))
         
     | 
| 
       5 
     | 
    
         
            -
                    unless model.respond_to?(:pg_search_multisearchable_options)
         
     | 
| 
       6 
     | 
    
         
            -
                      raise ModelNotMultisearchable.new(model)
         
     | 
| 
       7 
     | 
    
         
            -
                    end
         
     | 
| 
      
 5 
     | 
    
         
            +
                    raise ModelNotMultisearchable.new(model) unless model.respond_to?(:pg_search_multisearchable_options)
         
     | 
| 
       8 
6 
     | 
    
         | 
| 
       9 
7 
     | 
    
         
             
                    @model = model
         
     | 
| 
       10 
8 
     | 
    
         
             
                    @time_source = time_source
         
     | 
| 
         @@ -65,9 +63,7 @@ module PgSearch 
     | 
|
| 
       65 
63 
     | 
    
         
             
                    clause = ""
         
     | 
| 
       66 
64 
     | 
    
         
             
                    if model.column_names.include? model.inheritance_column
         
     | 
| 
       67 
65 
     | 
    
         
             
                      clause = "WHERE"
         
     | 
| 
       68 
     | 
    
         
            -
                      if model.base_class == model
         
     | 
| 
       69 
     | 
    
         
            -
                        clause = "#{clause} #{model.inheritance_column} IS NULL OR"
         
     | 
| 
       70 
     | 
    
         
            -
                      end
         
     | 
| 
      
 66 
     | 
    
         
            +
                      clause = "#{clause} #{model.inheritance_column} IS NULL OR" if model.base_class == model
         
     | 
| 
       71 
67 
     | 
    
         
             
                      clause = "#{clause} #{model.inheritance_column} = #{model_name}"
         
     | 
| 
       72 
68 
     | 
    
         
             
                    end
         
     | 
| 
       73 
69 
     | 
    
         
             
                    clause
         
     | 
| 
         @@ -16,7 +16,7 @@ module PgSearch 
     | 
|
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                  scope
         
     | 
| 
       18 
18 
     | 
    
         
             
                    .joins(rank_join(rank_table_alias))
         
     | 
| 
       19 
     | 
    
         
            -
                    .order("#{rank_table_alias}.rank DESC, #{order_within_rank}")
         
     | 
| 
      
 19 
     | 
    
         
            +
                    .order(Arel.sql("#{rank_table_alias}.rank DESC, #{order_within_rank}"))
         
     | 
| 
       20 
20 
     | 
    
         
             
                    .extend(DisableEagerLoading)
         
     | 
| 
       21 
21 
     | 
    
         
             
                    .extend(WithPgSearchRank)
         
     | 
| 
       22 
22 
     | 
    
         
             
                    .extend(WithPgSearchHighlight[feature_for(:tsearch)])
         
     | 
    
        data/lib/pg_search/version.rb
    CHANGED
    
    
    
        data/pg_search.gemspec
    CHANGED
    
    | 
         @@ -20,13 +20,13 @@ Gem::Specification.new do |s| 
     | 
|
| 
       20 
20 
     | 
    
         
             
              s.add_dependency 'activesupport', '>= 4.2'
         
     | 
| 
       21 
21 
     | 
    
         
             
              s.add_dependency 'arel', '>= 6'
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
              s.add_development_dependency ' 
     | 
| 
      
 23 
     | 
    
         
            +
              s.add_development_dependency 'codeclimate-test-reporter'
         
     | 
| 
       24 
24 
     | 
    
         
             
              s.add_development_dependency 'pry'
         
     | 
| 
      
 25 
     | 
    
         
            +
              s.add_development_dependency 'rake'
         
     | 
| 
       25 
26 
     | 
    
         
             
              s.add_development_dependency 'rspec', '>= 3.3'
         
     | 
| 
       26 
     | 
    
         
            -
              s.add_development_dependency 'with_model', '>= 1.2'
         
     | 
| 
       27 
27 
     | 
    
         
             
              s.add_development_dependency 'rubocop'
         
     | 
| 
       28 
     | 
    
         
            -
              s.add_development_dependency 'codeclimate-test-reporter'
         
     | 
| 
       29 
28 
     | 
    
         
             
              s.add_development_dependency 'simplecov'
         
     | 
| 
      
 29 
     | 
    
         
            +
              s.add_development_dependency 'with_model', '>= 1.2'
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
              s.required_ruby_version = '>= 2.1'
         
     | 
| 
       32 
32 
     | 
    
         
             
            end
         
     | 
| 
         @@ -131,7 +131,7 @@ describe PgSearch do 
     | 
|
| 
       131 
131 
     | 
    
         | 
| 
       132 
132 
     | 
    
         
             
                    results = ModelWithHasMany
         
     | 
| 
       133 
133 
     | 
    
         
             
                              .limit(1)
         
     | 
| 
       134 
     | 
    
         
            -
                              .order("#{ModelWithHasMany.quoted_table_name}.id ASC")
         
     | 
| 
      
 134 
     | 
    
         
            +
                              .order(Arel.sql("#{ModelWithHasMany.quoted_table_name}.id ASC"))
         
     | 
| 
       135 
135 
     | 
    
         
             
                              .with_associated('foo bar')
         
     | 
| 
       136 
136 
     | 
    
         | 
| 
       137 
137 
     | 
    
         
             
                    expect(results.map(&:title)).to match_array(included.map(&:title))
         
     | 
| 
         @@ -100,10 +100,10 @@ describe PgSearch::Multisearch::Rebuilder do 
     | 
|
| 
       100 
100 
     | 
    
         
             
                      end
         
     | 
| 
       101 
101 
     | 
    
         | 
| 
       102 
102 
     | 
    
         
             
                      it "should execute the default SQL" do
         
     | 
| 
       103 
     | 
    
         
            -
                        time =  
     | 
| 
      
 103 
     | 
    
         
            +
                        time = Time.utc(2001, 1, 1, 0, 0, 0)
         
     | 
| 
       104 
104 
     | 
    
         
             
                        rebuilder = PgSearch::Multisearch::Rebuilder.new(Model, -> { time })
         
     | 
| 
       105 
105 
     | 
    
         | 
| 
       106 
     | 
    
         
            -
                        # Handle change in precision of  
     | 
| 
      
 106 
     | 
    
         
            +
                        # Handle change in precision of Time objects in SQL in Active Record 4.0.1
         
     | 
| 
       107 
107 
     | 
    
         
             
                        # https://github.com/rails/rails/commit/17f5d8e062909f1fcae25351834d8e89967b645e
         
     | 
| 
       108 
108 
     | 
    
         
             
                        expected_timestamp = has_microsecond_precision? ? "2001-01-01 00:00:00.000000" : "2001-01-01 00:00:00"
         
     | 
| 
       109 
109 
     | 
    
         | 
| 
         @@ -145,10 +145,10 @@ describe PgSearch::Multisearch::Rebuilder do 
     | 
|
| 
       145 
145 
     | 
    
         
             
                        end
         
     | 
| 
       146 
146 
     | 
    
         | 
| 
       147 
147 
     | 
    
         
             
                        it "generates SQL with the correct primary key" do
         
     | 
| 
       148 
     | 
    
         
            -
                          time =  
     | 
| 
      
 148 
     | 
    
         
            +
                          time = Time.utc(2001, 1, 1, 0, 0, 0)
         
     | 
| 
       149 
149 
     | 
    
         
             
                          rebuilder = PgSearch::Multisearch::Rebuilder.new(ModelWithNonStandardPrimaryKey, -> { time })
         
     | 
| 
       150 
150 
     | 
    
         | 
| 
       151 
     | 
    
         
            -
                          # Handle change in precision of  
     | 
| 
      
 151 
     | 
    
         
            +
                          # Handle change in precision of Time objects in SQL in Active Record 4.0.1
         
     | 
| 
       152 
152 
     | 
    
         
             
                          # https://github.com/rails/rails/commit/17f5d8e062909f1fcae25351834d8e89967b645e
         
     | 
| 
       153 
153 
     | 
    
         
             
                          expected_timestamp = has_microsecond_precision? ? "2001-01-01 00:00:00.000000" : "2001-01-01 00:00:00"
         
     | 
| 
       154 
154 
     | 
    
         | 
    
        data/spec/lib/pg_search_spec.rb
    CHANGED
    
    | 
         @@ -1,5 +1,18 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "spec_helper"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            # For AR 5 and greater, the association reflection's cache needs be cleared
         
     | 
| 
      
 4 
     | 
    
         
            +
            # because we're stubbing the related constants.
         
     | 
| 
      
 5 
     | 
    
         
            +
            class << PgSearch::Document
         
     | 
| 
      
 6 
     | 
    
         
            +
              if ActiveRecord::VERSION::MAJOR >= 5
         
     | 
| 
      
 7 
     | 
    
         
            +
                def clear_searchable_cache
         
     | 
| 
      
 8 
     | 
    
         
            +
                  reflect_on_association(:searchable).clear_association_scope_cache
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
              else
         
     | 
| 
      
 11 
     | 
    
         
            +
                def clear_searchable_cache
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
       3 
16 
     | 
    
         
             
            describe PgSearch do
         
     | 
| 
       4 
17 
     | 
    
         
             
              describe ".multisearch" do
         
     | 
| 
       5 
18 
     | 
    
         
             
                with_table "pg_search_documents", {}, &DOCUMENTS_SCHEMA
         
     | 
| 
         @@ -18,7 +31,10 @@ describe PgSearch do 
     | 
|
| 
       18 
31 
     | 
    
         | 
| 
       19 
32 
     | 
    
         
             
                context "with PgSearch.multisearch_options set to a Hash" do
         
     | 
| 
       20 
33 
     | 
    
         
             
                  before { allow(PgSearch).to receive(:multisearch_options).and_return(:using => :dmetaphone) }
         
     | 
| 
       21 
     | 
    
         
            -
                  subject  
     | 
| 
      
 34 
     | 
    
         
            +
                  subject do
         
     | 
| 
      
 35 
     | 
    
         
            +
                    PgSearch::Document.clear_searchable_cache
         
     | 
| 
      
 36 
     | 
    
         
            +
                    PgSearch.multisearch(query).map(&:searchable)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
       22 
38 
     | 
    
         | 
| 
       23 
39 
     | 
    
         
             
                  with_model :MultisearchableModel do
         
     | 
| 
       24 
40 
     | 
    
         
             
                    table do |t|
         
     | 
| 
         @@ -36,7 +52,10 @@ describe PgSearch do 
     | 
|
| 
       36 
52 
     | 
    
         
             
                end
         
     | 
| 
       37 
53 
     | 
    
         | 
| 
       38 
54 
     | 
    
         
             
                context "with PgSearch.multisearch_options set to a Proc" do
         
     | 
| 
       39 
     | 
    
         
            -
                  subject  
     | 
| 
      
 55 
     | 
    
         
            +
                  subject do
         
     | 
| 
      
 56 
     | 
    
         
            +
                    PgSearch::Document.clear_searchable_cache
         
     | 
| 
      
 57 
     | 
    
         
            +
                    PgSearch.multisearch(query, soundalike).map(&:searchable)
         
     | 
| 
      
 58 
     | 
    
         
            +
                  end
         
     | 
| 
       40 
59 
     | 
    
         | 
| 
       41 
60 
     | 
    
         
             
                  before do
         
     | 
| 
       42 
61 
     | 
    
         
             
                    allow(PgSearch).to receive(:multisearch_options) do
         
     | 
| 
         @@ -140,6 +159,7 @@ describe PgSearch do 
     | 
|
| 
       140 
159 
     | 
    
         | 
| 
       141 
160 
     | 
    
         
             
                      PgSearch::Multisearch.rebuild(SearchableSubclassModel)
         
     | 
| 
       142 
161 
     | 
    
         | 
| 
      
 162 
     | 
    
         
            +
                      PgSearch::Document.clear_searchable_cache
         
     | 
| 
       143 
163 
     | 
    
         
             
                      expect(PgSearch::Document.count).to be 1
         
     | 
| 
       144 
164 
     | 
    
         
             
                      expect(PgSearch::Document.first.searchable.class).to be SearchableSubclassModel
         
     | 
| 
       145 
165 
     | 
    
         
             
                      expect(PgSearch::Document.first.searchable).to eq expected
         
     | 
| 
         @@ -153,6 +173,7 @@ describe PgSearch do 
     | 
|
| 
       153 
173 
     | 
    
         
             
                      PgSearch::Multisearch.rebuild(SearchableSubclassModel)
         
     | 
| 
       154 
174 
     | 
    
         
             
                      expect(PgSearch::Document.count).to be 2
         
     | 
| 
       155 
175 
     | 
    
         | 
| 
      
 176 
     | 
    
         
            +
                      PgSearch::Document.clear_searchable_cache
         
     | 
| 
       156 
177 
     | 
    
         
             
                      classes = PgSearch::Document.all.collect {|d| d.searchable.class }
         
     | 
| 
       157 
178 
     | 
    
         
             
                      expect(classes).to include SearchableSubclassModel
         
     | 
| 
       158 
179 
     | 
    
         
             
                      expect(classes).to include AnotherSearchableSubclassModel
         
     | 
| 
         @@ -223,7 +244,7 @@ describe PgSearch do 
     | 
|
| 
       223 
244 
     | 
    
         
             
                      @multisearch_enabled_inside = PgSearch.multisearch_enabled?
         
     | 
| 
       224 
245 
     | 
    
         
             
                      raise
         
     | 
| 
       225 
246 
     | 
    
         
             
                    end
         
     | 
| 
       226 
     | 
    
         
            -
                  rescue  
     | 
| 
      
 247 
     | 
    
         
            +
                  rescue StandardError
         
     | 
| 
       227 
248 
     | 
    
         
             
                  end
         
     | 
| 
       228 
249 
     | 
    
         | 
| 
       229 
250 
     | 
    
         
             
                  @multisearch_enabled_after = PgSearch.multisearch_enabled?
         
     | 
    
        data/spec/support/database.rb
    CHANGED
    
    | 
         @@ -42,7 +42,7 @@ def install_extension(name) 
     | 
|
| 
       42 
42 
     | 
    
         
             
              extension = connection.execute "SELECT * FROM pg_catalog.pg_extension WHERE extname = '#{name}';"
         
     | 
| 
       43 
43 
     | 
    
         
             
              return unless extension.none?
         
     | 
| 
       44 
44 
     | 
    
         
             
              connection.execute "CREATE EXTENSION #{name};"
         
     | 
| 
       45 
     | 
    
         
            -
            rescue => exception 
     | 
| 
      
 45 
     | 
    
         
            +
            rescue StandardError => exception
         
     | 
| 
       46 
46 
     | 
    
         
             
              at_exit do
         
     | 
| 
       47 
47 
     | 
    
         
             
                puts "-" * 80
         
     | 
| 
       48 
48 
     | 
    
         
             
                puts "Please install the #{name} extension"
         
     | 
| 
         @@ -54,7 +54,7 @@ end 
     | 
|
| 
       54 
54 
     | 
    
         
             
            def install_extension_if_missing(name, query, expected_result)
         
     | 
| 
       55 
55 
     | 
    
         
             
              result = ActiveRecord::Base.connection.select_value(query)
         
     | 
| 
       56 
56 
     | 
    
         
             
              raise "Unexpected output for #{query}: #{result.inspect}" unless result.downcase == expected_result.downcase
         
     | 
| 
       57 
     | 
    
         
            -
            rescue  
     | 
| 
      
 57 
     | 
    
         
            +
            rescue StandardError
         
     | 
| 
       58 
58 
     | 
    
         
             
              install_extension(name)
         
     | 
| 
       59 
59 
     | 
    
         
             
            end
         
     | 
| 
       60 
60 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: pg_search
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.1.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Grant Hutchins
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2017- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2017-12-25 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: activerecord
         
     | 
| 
         @@ -54,7 +54,7 @@ dependencies: 
     | 
|
| 
       54 
54 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       55 
55 
     | 
    
         
             
                    version: '6'
         
     | 
| 
       56 
56 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       57 
     | 
    
         
            -
              name:  
     | 
| 
      
 57 
     | 
    
         
            +
              name: codeclimate-test-reporter
         
     | 
| 
       58 
58 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       59 
59 
     | 
    
         
             
                requirements:
         
     | 
| 
       60 
60 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -82,33 +82,33 @@ dependencies: 
     | 
|
| 
       82 
82 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       83 
83 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       84 
84 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       85 
     | 
    
         
            -
              name:  
     | 
| 
      
 85 
     | 
    
         
            +
              name: rake
         
     | 
| 
       86 
86 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       87 
87 
     | 
    
         
             
                requirements:
         
     | 
| 
       88 
88 
     | 
    
         
             
                - - ">="
         
     | 
| 
       89 
89 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       90 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 90 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       91 
91 
     | 
    
         
             
              type: :development
         
     | 
| 
       92 
92 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       93 
93 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       94 
94 
     | 
    
         
             
                requirements:
         
     | 
| 
       95 
95 
     | 
    
         
             
                - - ">="
         
     | 
| 
       96 
96 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       97 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 97 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       98 
98 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       99 
     | 
    
         
            -
              name:  
     | 
| 
      
 99 
     | 
    
         
            +
              name: rspec
         
     | 
| 
       100 
100 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       101 
101 
     | 
    
         
             
                requirements:
         
     | 
| 
       102 
102 
     | 
    
         
             
                - - ">="
         
     | 
| 
       103 
103 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       104 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 104 
     | 
    
         
            +
                    version: '3.3'
         
     | 
| 
       105 
105 
     | 
    
         
             
              type: :development
         
     | 
| 
       106 
106 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       107 
107 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       108 
108 
     | 
    
         
             
                requirements:
         
     | 
| 
       109 
109 
     | 
    
         
             
                - - ">="
         
     | 
| 
       110 
110 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       111 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 111 
     | 
    
         
            +
                    version: '3.3'
         
     | 
| 
       112 
112 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       113 
113 
     | 
    
         
             
              name: rubocop
         
     | 
| 
       114 
114 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -124,7 +124,7 @@ dependencies: 
     | 
|
| 
       124 
124 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       125 
125 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       126 
126 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       127 
     | 
    
         
            -
              name:  
     | 
| 
      
 127 
     | 
    
         
            +
              name: simplecov
         
     | 
| 
       128 
128 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       129 
129 
     | 
    
         
             
                requirements:
         
     | 
| 
       130 
130 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -138,19 +138,19 @@ dependencies: 
     | 
|
| 
       138 
138 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       139 
139 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       140 
140 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       141 
     | 
    
         
            -
              name:  
     | 
| 
      
 141 
     | 
    
         
            +
              name: with_model
         
     | 
| 
       142 
142 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       143 
143 
     | 
    
         
             
                requirements:
         
     | 
| 
       144 
144 
     | 
    
         
             
                - - ">="
         
     | 
| 
       145 
145 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       146 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 146 
     | 
    
         
            +
                    version: '1.2'
         
     | 
| 
       147 
147 
     | 
    
         
             
              type: :development
         
     | 
| 
       148 
148 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       149 
149 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       150 
150 
     | 
    
         
             
                requirements:
         
     | 
| 
       151 
151 
     | 
    
         
             
                - - ">="
         
     | 
| 
       152 
152 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       153 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 153 
     | 
    
         
            +
                    version: '1.2'
         
     | 
| 
       154 
154 
     | 
    
         
             
            description: PgSearch builds Active Record named scopes that take advantage of PostgreSQL's
         
     | 
| 
       155 
155 
     | 
    
         
             
              full text search
         
     | 
| 
       156 
156 
     | 
    
         
             
            email:
         
     | 
| 
         @@ -241,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       241 
241 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       242 
242 
     | 
    
         
             
            requirements: []
         
     | 
| 
       243 
243 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       244 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 244 
     | 
    
         
            +
            rubygems_version: 2.6.13
         
     | 
| 
       245 
245 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       246 
246 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       247 
247 
     | 
    
         
             
            summary: PgSearch builds Active Record named scopes that take advantage of PostgreSQL's
         
     |