diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa1a95aeb..79b850124 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: ruby: [ '2.7', '3.0', '3.1', '3.2' ] - rails: [ '5_0', '5_1', '5_2', '6_0', '6_1', '7_0' ] + rails: [ '5_0', '5_1', '5_2', '6_0', '6_1', '7_0', '7_1' ] database: [ 'mysql2', 'postgresql' ] sphinx_version: [ '2.2.11', '3.4.1' ] sphinx_engine: [ 'sphinx' ] @@ -74,7 +74,7 @@ jobs: fail-fast: false matrix: ruby: [ '2.7', '3.0', '3.1', '3.2' ] - rails: [ '5_0', '5_1', '5_2', '6_0', '6_1', '7_0' ] + rails: [ '5_0', '5_1', '5_2', '6_0', '6_1', '7_0', '7_1' ] database: [ 'mysql2', 'postgresql' ] sphinx_version: [ '4.0.2', '6.0.0' ] sphinx_engine: [ 'manticore' ] diff --git a/Appraisals b/Appraisals index 1dc1d01f7..59cda54c2 100644 --- a/Appraisals +++ b/Appraisals @@ -45,3 +45,9 @@ appraise 'rails_7_0' do gem 'mysql2', '~> 0.5.0', :platform => :ruby gem 'pg', '~> 1.0', :platform => :ruby end if RUBY_PLATFORM != 'java' && RUBY_VERSION.to_f >= 2.7 + +appraise 'rails_7_1' do + gem 'rails', '~> 7.1.0' + gem 'mysql2', '~> 0.5.0', :platform => :ruby + gem 'pg', '~> 1.0', :platform => :ruby +end if RUBY_PLATFORM != 'java' && RUBY_VERSION.to_f >= 2.7 diff --git a/lib/thinking_sphinx/active_record/filter_reflection.rb b/lib/thinking_sphinx/active_record/filter_reflection.rb index d72f42218..816520b0e 100644 --- a/lib/thinking_sphinx/active_record/filter_reflection.rb +++ b/lib/thinking_sphinx/active_record/filter_reflection.rb @@ -2,7 +2,7 @@ class ThinkingSphinx::ActiveRecord::FilterReflection ReflectionGenerator = case ActiveRecord::VERSION::STRING.to_f - when 5.2..7.0 + when 5.2..7.1 ThinkingSphinx::ActiveRecord::Depolymorph::OverriddenReflection when 4.1..5.1 ThinkingSphinx::ActiveRecord::Depolymorph::AssociationReflection diff --git a/lib/thinking_sphinx/active_record/log_subscriber.rb b/lib/thinking_sphinx/active_record/log_subscriber.rb index c610ec982..7187b6ce3 100644 --- a/lib/thinking_sphinx/active_record/log_subscriber.rb +++ b/lib/thinking_sphinx/active_record/log_subscriber.rb @@ -2,24 +2,36 @@ class ThinkingSphinx::ActiveRecord::LogSubscriber < ActiveSupport::LogSubscriber def guard(event) - identifier = color 'Sphinx', GREEN, true + identifier = colored_text "Sphinx" warn " #{identifier} #{event.payload[:guard]}" end def message(event) - identifier = color 'Sphinx', GREEN, true + identifier = colored_text "Sphinx" debug " #{identifier} #{event.payload[:message]}" end def query(event) - identifier = color('Sphinx Query (%.1fms)' % event.duration, GREEN, true) + identifier = colored_text("Sphinx Query (%.1fms)" % event.duration) debug " #{identifier} #{event.payload[:query]}" end def caution(event) - identifier = color 'Sphinx', GREEN, true + identifier = colored_text "Sphinx" warn " #{identifier} #{event.payload[:caution]}" end + + private + + if Rails.gem_version >= Gem::Version.new("7.1.0") + def colored_text(text) + color text, GREEN, bold: true + end + else + def colored_text(text) + color text, GREEN, true + end + end end ThinkingSphinx::ActiveRecord::LogSubscriber.attach_to :thinking_sphinx diff --git a/spec/thinking_sphinx/active_record/callbacks/update_callbacks_spec.rb b/spec/thinking_sphinx/active_record/callbacks/update_callbacks_spec.rb index d13a40e50..9186683b1 100644 --- a/spec/thinking_sphinx/active_record/callbacks/update_callbacks_spec.rb +++ b/spec/thinking_sphinx/active_record/callbacks/update_callbacks_spec.rb @@ -60,7 +60,7 @@ module Callbacks; end it "builds an update query with only updateable attributes that have changed" do expect(Riddle::Query).to receive(:update). - with('article_core', 3, 'bar' => 7).and_return('SphinxQL') + with('article_core', 3, { 'bar' => 7 }).and_return('SphinxQL') callbacks.after_update end diff --git a/spec/thinking_sphinx/active_record/interpreter_spec.rb b/spec/thinking_sphinx/active_record/interpreter_spec.rb index d408324df..68d61f19e 100644 --- a/spec/thinking_sphinx/active_record/interpreter_spec.rb +++ b/spec/thinking_sphinx/active_record/interpreter_spec.rb @@ -93,7 +93,7 @@ it "passes through options to the attribute" do expect(ThinkingSphinx::ActiveRecord::Attribute).to receive(:new). - with(model, column, :as => :other_name).and_return(attribute) + with(model, column, { :as => :other_name }).and_return(attribute) instance.has column, :as => :other_name end @@ -141,7 +141,7 @@ it "passes through options to the field" do expect(ThinkingSphinx::ActiveRecord::Field).to receive(:new). - with(model, column, :as => :other_name).and_return(field) + with(model, column, { :as => :other_name }).and_return(field) instance.indexes column, :as => :other_name end @@ -230,19 +230,19 @@ end it "sends through a hash if provided" do - expect(source).to receive(:set_database_settings).with(:foo => :bar) + expect(source).to receive(:set_database_settings).with({ :foo => :bar }) instance.set_database :foo => :bar end it "finds the environment settings if given a string key" do - expect(source).to receive(:set_database_settings).with(:baz => 'qux') + expect(source).to receive(:set_database_settings).with({ :baz => 'qux' }) instance.set_database 'other' end it "finds the environment settings if given a symbol key" do - expect(source).to receive(:set_database_settings).with(:baz => 'qux') + expect(source).to receive(:set_database_settings).with({ :baz => 'qux' }) instance.set_database :other end diff --git a/spec/thinking_sphinx/excerpter_spec.rb b/spec/thinking_sphinx/excerpter_spec.rb index f27a626b9..abb6e0ae7 100644 --- a/spec/thinking_sphinx/excerpter_spec.rb +++ b/spec/thinking_sphinx/excerpter_spec.rb @@ -28,9 +28,10 @@ :before_match => '', :chunk_separator => ' -- ') expect(Riddle::Query).to receive(:snippets). - with('all of the words', 'index', 'all words', + with('all of the words', 'index', 'all words', { :before_match => '', :after_match => '', - :chunk_separator => ' -- '). + :chunk_separator => ' -- ' + }). and_return('CALL SNIPPETS') excerpter.excerpt!('all of the words') diff --git a/spec/thinking_sphinx/index_spec.rb b/spec/thinking_sphinx/index_spec.rb index 0fd41eb67..7d16e2767 100644 --- a/spec/thinking_sphinx/index_spec.rb +++ b/spec/thinking_sphinx/index_spec.rb @@ -19,7 +19,7 @@ it "creates an ActiveRecord index" do expect(ThinkingSphinx::ActiveRecord::Index).to receive(:new). - with(:user, :with => :active_record).and_return index + with(:user, { :with => :active_record }).and_return index ThinkingSphinx::Index.define(:user, :with => :active_record) end @@ -100,7 +100,7 @@ it "creates a real-time index" do expect(ThinkingSphinx::RealTime::Index).to receive(:new). - with(:user, :with => :real_time).and_return index + with(:user, { :with => :real_time }).and_return index ThinkingSphinx::Index.define(:user, :with => :real_time) end diff --git a/spec/thinking_sphinx/middlewares/sphinxql_spec.rb b/spec/thinking_sphinx/middlewares/sphinxql_spec.rb index ff966d51c..96f1d7605 100644 --- a/spec/thinking_sphinx/middlewares/sphinxql_spec.rb +++ b/spec/thinking_sphinx/middlewares/sphinxql_spec.rb @@ -61,7 +61,7 @@ class SphinxQLSubclass allow(index_set.first).to receive_messages :reference => :user expect(set_class).to receive(:new). - with(:classes => [klass], :indices => ['user_core']). + with({ :classes => [klass], :indices => ['user_core'] }). and_return(index_set) middleware.call [context] @@ -215,7 +215,7 @@ def self.table_name; 'cats'; end end it "filters out deleted values by default" do - expect(sphinx_sql).to receive(:where).with(:sphinx_deleted => false). + expect(sphinx_sql).to receive(:where).with({ :sphinx_deleted => false }). and_return(sphinx_sql) middleware.call [context] @@ -253,7 +253,7 @@ def self.table_name; 'cats'; end search.options[:with_all] = {:tag_ids => [1, 7]} expect(sphinx_sql).to receive(:where_all). - with(:tag_ids => [1, 7]).and_return(sphinx_sql) + with({ :tag_ids => [1, 7] }).and_return(sphinx_sql) middleware.call [context] end @@ -262,7 +262,7 @@ def self.table_name; 'cats'; end search.options[:without_all] = {:tag_ids => [1, 7]} expect(sphinx_sql).to receive(:where_not_all). - with(:tag_ids => [1, 7]).and_return(sphinx_sql) + with({ :tag_ids => [1, 7] }).and_return(sphinx_sql) middleware.call [context] end diff --git a/spec/thinking_sphinx/panes/excerpts_pane_spec.rb b/spec/thinking_sphinx/panes/excerpts_pane_spec.rb index 1c3d2cbf3..3adf50b89 100644 --- a/spec/thinking_sphinx/panes/excerpts_pane_spec.rb +++ b/spec/thinking_sphinx/panes/excerpts_pane_spec.rb @@ -45,7 +45,7 @@ module Panes; end search.options[:excerpts] = {:before_match => 'foo'} expect(ThinkingSphinx::Excerpter).to receive(:new). - with(anything, anything, :before_match => 'foo').and_return(excerpter) + with(anything, anything, { :before_match => 'foo' }).and_return(excerpter) pane.excerpts end diff --git a/spec/thinking_sphinx/real_time/interpreter_spec.rb b/spec/thinking_sphinx/real_time/interpreter_spec.rb index 44b3d6727..eb6f789dd 100644 --- a/spec/thinking_sphinx/real_time/interpreter_spec.rb +++ b/spec/thinking_sphinx/real_time/interpreter_spec.rb @@ -49,7 +49,7 @@ it "passes through options to the attribute" do expect(ThinkingSphinx::RealTime::Attribute).to receive(:new). - with(column, :as => :other_name).and_return(attribute) + with(column, { :as => :other_name }).and_return(attribute) instance.has column, :as => :other_name end @@ -84,7 +84,7 @@ it "passes through options to the field" do expect(ThinkingSphinx::RealTime::Field).to receive(:new). - with(column, :as => :other_name).and_return(field) + with(column, { :as => :other_name }).and_return(field) instance.indexes column, :as => :other_name end @@ -112,7 +112,7 @@ it "adds the _sort suffix to the field's name" do expect(ThinkingSphinx::RealTime::Attribute).to receive(:new). - with(column, :as => :col_sort, :type => :string). + with(column, { :as => :col_sort, :type => :string }). and_return(attribute) instance.indexes column, :sortable => true @@ -120,7 +120,7 @@ it "respects given aliases" do expect(ThinkingSphinx::RealTime::Attribute).to receive(:new). - with(column, :as => :other_sort, :type => :string). + with(column, { :as => :other_sort, :type => :string }). and_return(attribute) instance.indexes column, :sortable => true, :as => :other @@ -128,7 +128,7 @@ it "respects symbols instead of columns" do expect(ThinkingSphinx::RealTime::Attribute).to receive(:new). - with(:title, :as => :title_sort, :type => :string). + with(:title, { :as => :title_sort, :type => :string }). and_return(attribute) instance.indexes :title, :sortable => true diff --git a/spec/thinking_sphinx_spec.rb b/spec/thinking_sphinx_spec.rb index b0ed5bb53..775966e77 100644 --- a/spec/thinking_sphinx_spec.rb +++ b/spec/thinking_sphinx_spec.rb @@ -16,7 +16,7 @@ end it "passes through the given query and options" do - expect(ThinkingSphinx::Search).to receive(:new).with('foo', :bar => :baz). + expect(ThinkingSphinx::Search).to receive(:new).with('foo', { :bar => :baz }). and_return(search) ThinkingSphinx.count('foo', :bar => :baz) @@ -35,7 +35,7 @@ end it "passes through the given query and options" do - expect(ThinkingSphinx::Search).to receive(:new).with('foo', :bar => :baz). + expect(ThinkingSphinx::Search).to receive(:new).with('foo', { :bar => :baz }). and_return(search) ThinkingSphinx.search('foo', :bar => :baz) diff --git a/thinking-sphinx.gemspec b/thinking-sphinx.gemspec index 358b0afb1..dac9a21a6 100644 --- a/thinking-sphinx.gemspec +++ b/thinking-sphinx.gemspec @@ -30,7 +30,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'appraisal', '~> 1.0.2' s.add_development_dependency 'combustion', '~> 1.1' - s.add_development_dependency 'database_cleaner', '~> 1.6.0' - s.add_development_dependency 'rspec', '~> 3.7.0' + s.add_development_dependency 'database_cleaner', '~> 2.0.2' + s.add_development_dependency 'rspec', '~> 3.12.0' s.add_development_dependency 'rspec-retry', '~> 0.5.6' end