From b2ee12128d3958e0512153e7a9e8df88be7abb19 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 5 Sep 2024 09:09:37 +0100 Subject: [PATCH 01/10] [CI] Updates GitHub Actions Lock bundler to v 2.4.22, since Ruby old :( Removes unnecessary package installation Updates STACK_VERSION Adds jruby 9.4 Run bundle install with BUNDLE_GEMFILE Updates actions/checkout sqlite for Rails 5 shenanigans --- .github/workflows/2.7.yml | 46 --------------------- .github/workflows/{2.6.yml => 7x_tests.yml} | 16 +++---- .github/workflows/jruby.yml | 11 ++--- elasticsearch-model/Rakefile | 1 + elasticsearch-model/gemfiles/5.0.gemfile | 2 +- 5 files changed, 16 insertions(+), 60 deletions(-) delete mode 100644 .github/workflows/2.7.yml rename .github/workflows/{2.6.yml => 7x_tests.yml} (84%) diff --git a/.github/workflows/2.7.yml b/.github/workflows/2.7.yml deleted file mode 100644 index 8bfd9b66f..000000000 --- a/.github/workflows/2.7.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Ruby 2.7 -on: - push: - branches: - - main - pull_request: - branches: - - main - workflow_dispatch: - branches: - - '*' -jobs: - tests: - env: - TEST_ES_SERVER: http://localhost:9200 - RAILS_VERSIONS: '5.0,6.0' - strategy: - fail-fast: false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Increase system limits - run: | - sudo swapoff -a - sudo sysctl -w vm.swappiness=1 - sudo sysctl -w fs.file-max=262144 - sudo sysctl -w vm.max_map_count=262144 - - uses: elastic/elastic-github-actions/elasticsearch@master - with: - stack-version: 7.x-SNAPSHOT - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.7 - - name: Bundle - run: | - sudo apt-get install libsqlite3-dev - gem install bundler - bundle install - bundle exec rake bundle:clean - bundle exec rake bundle:install - - name: Test elasticsearch-rails - run: cd elasticsearch-rails && bundle exec rake test:all - - name: Test elasticsearch-persistence - run: cd elasticsearch-persistence && bundle exec rake test:all - - name: Test elasticsearch-model - run: cd elasticsearch-model && bundle exec rake test:all diff --git a/.github/workflows/2.6.yml b/.github/workflows/7x_tests.yml similarity index 84% rename from .github/workflows/2.6.yml rename to .github/workflows/7x_tests.yml index c003a58e5..03b96fbda 100644 --- a/.github/workflows/2.6.yml +++ b/.github/workflows/7x_tests.yml @@ -1,14 +1,12 @@ -name: Ruby 2.6 +name: 7.x tests on: push: branches: - - main + - 7.x pull_request: branches: - - main + - 7.x workflow_dispatch: - branches: - - '*' jobs: tests: env: @@ -16,9 +14,11 @@ jobs: RAILS_VERSIONS: '5.0,6.0' strategy: fail-fast: false + matrix: + ruby: ['2.6', '2.7', '3.0'] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Increase system limits run: | sudo swapoff -a @@ -30,11 +30,11 @@ jobs: stack-version: 7.x-SNAPSHOT - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.6 + ruby-version: ${{ matrix.ruby }} - name: Bundle run: | sudo apt-get install libsqlite3-dev - gem install bundler + gem install bundler -v 2.4.22 bundle install bundle exec rake bundle:clean bundle exec rake bundle:install diff --git a/.github/workflows/jruby.yml b/.github/workflows/jruby.yml index 7a3ec1be7..c1ee9e619 100644 --- a/.github/workflows/jruby.yml +++ b/.github/workflows/jruby.yml @@ -2,10 +2,10 @@ name: JRuby on: push: branches: - - main + - 7.x pull_request: branches: - - main + - 7.x workflow_dispatch: branches: - '*' @@ -16,6 +16,8 @@ jobs: RAILS_VERSIONS: '5.0,6.0' strategy: fail-fast: false + matrix: + ruby: [ 'jruby-9.3', 'jruby-9.4' ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -27,13 +29,12 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 7.x-SNAPSHOT + stack-version: 7.17-SNAPSHOT - uses: ruby/setup-ruby@v1 with: - ruby-version: jruby-9.3 + ruby-version: ${{ matrix.ruby }} - name: Bundle run: | - sudo apt-get install libsqlite3-dev gem install bundler bundle install bundle exec rake bundle:clean diff --git a/elasticsearch-model/Rakefile b/elasticsearch-model/Rakefile index 6e03532b0..bb39d37e3 100644 --- a/elasticsearch-model/Rakefile +++ b/elasticsearch-model/Rakefile @@ -52,6 +52,7 @@ namespace :test do puts '-' * 80 gemfiles.each do |gemfile| puts "GEMFILE: #{gemfile}" + sh "BUNDLE_GEMFILE='#{File.expand_path("../gemfiles/#{gemfile}", __FILE__)}' bundle install" sh "BUNDLE_GEMFILE='#{File.expand_path("../gemfiles/#{gemfile}", __FILE__)}' " \ ' bundle exec rspec' puts '-' * 80 diff --git a/elasticsearch-model/gemfiles/5.0.gemfile b/elasticsearch-model/gemfiles/5.0.gemfile index 8b1930961..f2897c71c 100644 --- a/elasticsearch-model/gemfiles/5.0.gemfile +++ b/elasticsearch-model/gemfiles/5.0.gemfile @@ -26,7 +26,7 @@ gemspec path: '../' gem 'activemodel', '~> 5' gem 'activerecord', '~> 5' -gem 'sqlite3' unless defined?(JRUBY_VERSION) +gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION) gem 'mongoid', '~> 6' group :development, :testing do From 9b45c9ea54cb926d387641bbfc621f2e994269b3 Mon Sep 17 00:00:00 2001 From: Colin MacKenzie IV Date: Fri, 12 Apr 2024 19:12:33 -0400 Subject: [PATCH 02/10] Require activesupport/all to more closely mirror a production Rails app. ActiveSupport patches Kernel to add `class_eval` but this behavior wasn't loaded in the test environment. This created a discrepancy between test and prod, causing tests to fail that should have passed and vice versa. Fully loading ActiveSupport makes the test environment more accurate. --- elasticsearch-model/spec/spec_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/elasticsearch-model/spec/spec_helper.rb b/elasticsearch-model/spec/spec_helper.rb index 413b5f03e..81f66656b 100644 --- a/elasticsearch-model/spec/spec_helper.rb +++ b/elasticsearch-model/spec/spec_helper.rb @@ -31,6 +31,10 @@ require 'yaml' require 'active_record' +# Load all of ActiveSupport to be sure of complete compatibility - +# see https://github.com/elastic/elasticsearch-rails/pull/1075 for details +require 'active_support/all' + unless defined?(ELASTICSEARCH_URL) ELASTICSEARCH_URL = ENV['ELASTICSEARCH_URL'] || "localhost:#{(ENV['TEST_CLUSTER_PORT'] || 9200)}" end From 8e6c03bbbfec922af5beba8a085b4f60c41cc454 Mon Sep 17 00:00:00 2001 From: Martin Streicher Date: Mon, 4 Mar 2024 11:06:38 -0500 Subject: [PATCH 03/10] Ensure subclasses are added to the registry --- elasticsearch-model/lib/elasticsearch/model.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/elasticsearch-model/lib/elasticsearch/model.rb b/elasticsearch-model/lib/elasticsearch/model.rb index af2f34cb6..849c5c4f0 100644 --- a/elasticsearch-model/lib/elasticsearch/model.rb +++ b/elasticsearch-model/lib/elasticsearch/model.rb @@ -114,6 +114,11 @@ class << self METHODS.each do |method| delegate method, to: :__elasticsearch__ unless self.public_instance_methods.include?(method) end + + def inherited(subclass) + super + Registry.add(subclass) if subclass.is_a?(Class) + end end end From 1ed9d58115dc0d6084667326946eba7dcd877832 Mon Sep 17 00:00:00 2001 From: Colin MacKenzie IV Date: Fri, 12 Apr 2024 19:11:44 -0400 Subject: [PATCH 04/10] Test that the model namespace isn't polluted. The goal of ClassMethodsProxy is to avoid polluting the target's namespace, but it was possible to do this by accident when calling `class_eval` before ActiveSupport was completely loaded. This test ensures the namespace isn't polluted, regardless of the load state of ActiveSupport. --- .../elasticsearch/model/adapters/active_record/import_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb index 1f5fe0847..fcd8a7ac4 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb @@ -52,6 +52,10 @@ it 'imports all documents' do expect(ImportArticle.search('*').results.total).to eq(10) end + + it "does not pollute the model's namespace" do + expect(ImportArticle.methods).not_to include(:__transform) + end end context 'when batch size is specified' do From 48bfd76e5d379646514491b71e679cd7eda538b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciek=20Dubi=C5=84ski?= Date: Wed, 27 Dec 2023 16:53:40 +0100 Subject: [PATCH 05/10] Address Rails 7.1 deprecation warning in elasticsearch-rails This PR switches the elasticsearch-rails gem to use a new signature of the ActiveSupport::LogSubscriber#color method when called in an app using Rails 7.1+. With older Rails, the gem uses the working, old signature. --- .../rails/instrumentation/log_subscriber.rb | 13 ++++- .../instrumentation/log_subscriber_spec.rb | 57 +++++++++++++++++++ elasticsearch-rails/spec/spec_helper.rb | 1 + 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb diff --git a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb index c388961c0..a60670a03 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb @@ -46,8 +46,19 @@ def search(event) payload = event.payload name = "#{payload[:klass]} #{payload[:name]} (#{event.duration.round(1)}ms)" search = payload[:search].inspect.gsub(/:(\w+)=>/, '\1: ') + debug %Q| #{color(name, GREEN, color_option(true))} #{colorize_logging ? "\e[2m#{search}\e[0m" : search}| + end + + private + + def color_option(bold_value) + new_color_syntax? ? { bold: bold_value } : bold_value + end + + def new_color_syntax? + return @new_color_syntax if defined?(@new_color_syntax) - debug %Q| #{color(name, GREEN, true)} #{colorize_logging ? "\e[2m#{search}\e[0m" : search}| + @new_color_syntax = ::Rails.respond_to?(:gem_version) && ::Rails.gem_version >= Gem::Version.new('7.1') end end diff --git a/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb b/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb new file mode 100644 index 000000000..7512f006a --- /dev/null +++ b/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb @@ -0,0 +1,57 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +require 'spec_helper' +require 'elasticsearch/rails/instrumentation/log_subscriber' + +describe Elasticsearch::Rails::Instrumentation::LogSubscriber do + subject(:instance) { described_class.new } + + let(:logger) { instance_double(Logger) } + + before do + allow(instance).to receive(:logger) { logger } + end + + describe "#search" do + subject { instance.search(event) } + + let(:event) { double("search.elasticsearch", duration: 1.2345, payload: { name: "execute", search: { query: { match_all: {}}}}) } + + it "logs the event" do + expect(instance).to receive(:color).with(" execute (1.2ms)", described_class::GREEN, { bold: true }).and_call_original + expect(logger).to receive(:debug?) { true } + expect(logger).to receive(:debug).with(" \e[1m\e[32m execute (1.2ms)\e[0m \e[2m{query: {match_all: {}}}\e[0m") + subject + end + + context "when Rails version is older" do + let(:rails_version) { "7.0.0" } + + before do + allow(::Rails).to receive(:gem_version) { Gem::Version.new(rails_version) } + end + + it "logs the event" do + expect(instance).to receive(:color).with(" execute (1.2ms)", described_class::GREEN, true).and_call_original + expect(logger).to receive(:debug?) { true } + expect(logger).to receive(:debug).with(" \e[1m\e[32m execute (1.2ms)\e[0m \e[2m{query: {match_all: {}}}\e[0m") + subject + end + end + end +end diff --git a/elasticsearch-rails/spec/spec_helper.rb b/elasticsearch-rails/spec/spec_helper.rb index e0a299964..966074211 100644 --- a/elasticsearch-rails/spec/spec_helper.rb +++ b/elasticsearch-rails/spec/spec_helper.rb @@ -20,6 +20,7 @@ require 'elasticsearch/model' require 'elasticsearch/rails' require 'rails/railtie' +require 'rails/version' require 'elasticsearch/rails/instrumentation' From 89a7e8df6d164b325a73b6f6e14330bb009233ba Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 13 Feb 2025 10:02:14 +0000 Subject: [PATCH 06/10] [CI] Updates Gemfiles --- .github/workflows/7x_tests.yml | 4 +-- elasticsearch-model/Rakefile | 3 +- elasticsearch-model/gemfiles/4.0.gemfile | 36 ------------------- elasticsearch-model/gemfiles/6.0.gemfile | 7 ++-- .../gemfiles/{5.0.gemfile => 7.0.gemfile} | 13 ++++--- .../gemfiles/{3.0.gemfile => 7.1.gemfile} | 15 ++++---- .../instrumentation/log_subscriber_spec.rb | 2 +- 7 files changed, 20 insertions(+), 60 deletions(-) delete mode 100644 elasticsearch-model/gemfiles/4.0.gemfile rename elasticsearch-model/gemfiles/{5.0.gemfile => 7.0.gemfile} (77%) rename elasticsearch-model/gemfiles/{3.0.gemfile => 7.1.gemfile} (76%) diff --git a/.github/workflows/7x_tests.yml b/.github/workflows/7x_tests.yml index 03b96fbda..aee138945 100644 --- a/.github/workflows/7x_tests.yml +++ b/.github/workflows/7x_tests.yml @@ -11,11 +11,11 @@ jobs: tests: env: TEST_ES_SERVER: http://localhost:9200 - RAILS_VERSIONS: '5.0,6.0' + RAILS_VERSIONS: '6.0,7.0' strategy: fail-fast: false matrix: - ruby: ['2.6', '2.7', '3.0'] + ruby: ['2.7', '3.0'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/elasticsearch-model/Rakefile b/elasticsearch-model/Rakefile index bb39d37e3..c5e8b73f0 100644 --- a/elasticsearch-model/Rakefile +++ b/elasticsearch-model/Rakefile @@ -21,8 +21,7 @@ desc 'Run unit tests' task default: 'test:all' task test: 'test:all' -gemfiles = ['5.0.gemfile', '6.0.gemfile'] -gemfiles << '4.0.gemfile' if RUBY_VERSION < '2.7' +gemfiles = ['6.0.gemfile', '7.0.gemfile'] GEMFILES = gemfiles.freeze namespace :bundle do diff --git a/elasticsearch-model/gemfiles/4.0.gemfile b/elasticsearch-model/gemfiles/4.0.gemfile deleted file mode 100644 index 944568fce..000000000 --- a/elasticsearch-model/gemfiles/4.0.gemfile +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# Usage: -# -# $ BUNDLE_GEMFILE=./gemfiles/4.0.gemfile bundle install -# $ BUNDLE_GEMFILE=./gemfiles/4.0.gemfile bundle exec rake test:integration - -source 'https://rubygems.org' - -gemspec path: '../' - -gem 'activemodel', '~> 4' -gem 'activerecord', '~> 4' -gem 'mongoid', '~> 5' -gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION) - -group :development, :testing do - gem 'bigdecimal', '~> 1' - gem 'pry-nav' - gem 'rspec' -end diff --git a/elasticsearch-model/gemfiles/6.0.gemfile b/elasticsearch-model/gemfiles/6.0.gemfile index 2461d66f0..82ae11d52 100644 --- a/elasticsearch-model/gemfiles/6.0.gemfile +++ b/elasticsearch-model/gemfiles/6.0.gemfile @@ -24,10 +24,9 @@ source 'https://rubygems.org' gemspec path: '../' -gem 'activemodel', '6.0.0' -gem 'activerecord', '6.0.0' -gem 'sqlite3' unless defined?(JRUBY_VERSION) -# gem 'mongoid', '~> 6' +gem 'activemodel', '6.0' +gem 'activerecord', '6.0' +gem 'activesupport', '6.0' group :development, :testing do gem 'pry-nav' diff --git a/elasticsearch-model/gemfiles/5.0.gemfile b/elasticsearch-model/gemfiles/7.0.gemfile similarity index 77% rename from elasticsearch-model/gemfiles/5.0.gemfile rename to elasticsearch-model/gemfiles/7.0.gemfile index f2897c71c..c7de126fe 100644 --- a/elasticsearch-model/gemfiles/5.0.gemfile +++ b/elasticsearch-model/gemfiles/7.0.gemfile @@ -17,19 +17,18 @@ # Usage: # -# $ BUNDLE_GEMFILE=./gemfiles/5.0.gemfile bundle install -# $ BUNDLE_GEMFILE=./gemfiles/5.0.gemfile bundle exec rake test:integration +# $ BUNDLE_GEMFILE=./gemfiles/6.0.gemfile bundle install +# $ BUNDLE_GEMFILE=./gemfiles/6.0.gemfile bundle exec rake test:integration source 'https://rubygems.org' gemspec path: '../' -gem 'activemodel', '~> 5' -gem 'activerecord', '~> 5' -gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION) -gem 'mongoid', '~> 6' +gem 'activemodel', '7.0' +gem 'activerecord', '7.0' +gem 'activesupport', '7.0' group :development, :testing do - gem 'rspec' gem 'pry-nav' + gem 'rspec' end diff --git a/elasticsearch-model/gemfiles/3.0.gemfile b/elasticsearch-model/gemfiles/7.1.gemfile similarity index 76% rename from elasticsearch-model/gemfiles/3.0.gemfile rename to elasticsearch-model/gemfiles/7.1.gemfile index 1641023d7..880f78aa8 100644 --- a/elasticsearch-model/gemfiles/3.0.gemfile +++ b/elasticsearch-model/gemfiles/7.1.gemfile @@ -17,19 +17,18 @@ # Usage: # -# $ BUNDLE_GEMFILE=./gemfiles/3.0.gemfile bundle install -# $ BUNDLE_GEMFILE=./gemfiles/3.0.gemfile bundle exec rake test:integration +# $ BUNDLE_GEMFILE=./gemfiles/6.0.gemfile bundle install +# $ BUNDLE_GEMFILE=./gemfiles/6.0.gemfile bundle exec rake test:integration source 'https://rubygems.org' gemspec path: '../' -gem 'activemodel', '>= 3.0' -gem 'activerecord', '~> 3.2' -gem 'mongoid', '>= 3.0' -gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION) +gem 'activemodel', '7.1' +gem 'activerecord', '7.1' +gem 'activesupport', '7.1' group :development, :testing do - gem 'rspec' gem 'pry-nav' -end \ No newline at end of file + gem 'rspec' +end diff --git a/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb b/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb index 7512f006a..3cf8b0cb3 100644 --- a/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb +++ b/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb @@ -54,4 +54,4 @@ end end end -end +end if version >= Gem::Version.new('7.1') From 770a6661acbff32763ed829ca3e7fa36fad5f050 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 13 Feb 2025 10:14:28 +0000 Subject: [PATCH 07/10] Updates serialization spec --- elasticsearch-model/elasticsearch-model.gemspec | 1 - .../model/adapters/active_record/serialization_spec.rb | 5 +++-- .../spec/instrumentation/log_subscriber_spec.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/elasticsearch-model/elasticsearch-model.gemspec b/elasticsearch-model/elasticsearch-model.gemspec index 0dc71775c..53fa08bda 100644 --- a/elasticsearch-model/elasticsearch-model.gemspec +++ b/elasticsearch-model/elasticsearch-model.gemspec @@ -63,6 +63,5 @@ Gem::Specification.new do |s| unless defined?(JRUBY_VERSION) s.add_development_dependency 'oj' s.add_development_dependency 'ruby-prof' - s.add_development_dependency 'sqlite3' end end diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb index 3f01c348b..2cafd4f8b 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb @@ -52,9 +52,10 @@ end context 'when a document is updated' do - before do - article.update_attributes(title: 'UPDATED', status: 'yellow') + article.update_attribute(:title, 'UPDATED') + article.update_attribute(:status, 'yellow') + ArticleWithCustomSerialization.__elasticsearch__.refresh_index! end diff --git a/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb b/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb index 3cf8b0cb3..2f024c832 100644 --- a/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb +++ b/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb @@ -54,4 +54,4 @@ end end end -end if version >= Gem::Version.new('7.1') +end if Gem::Version.new('7.1') <= Gem::Version.new(Rails::VERSION::STRING) From 5ca772fdba484a4a6c6139121a6b184ec2420be4 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 1 Sep 2025 14:06:47 +0100 Subject: [PATCH 08/10] Adds sqlite dev/test dependency --- elasticsearch-model/gemfiles/6.0.gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/elasticsearch-model/gemfiles/6.0.gemfile b/elasticsearch-model/gemfiles/6.0.gemfile index 82ae11d52..306b16802 100644 --- a/elasticsearch-model/gemfiles/6.0.gemfile +++ b/elasticsearch-model/gemfiles/6.0.gemfile @@ -31,4 +31,5 @@ gem 'activesupport', '6.0' group :development, :testing do gem 'pry-nav' gem 'rspec' + gem 'sqlite3' end From 092e647e3098756fb5f57c4705e518b6bf6e760b Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 8 Oct 2025 09:33:20 +0100 Subject: [PATCH 09/10] [CI] Adds QUIET:true, drops Ruby 2.7 in tests fixup --- .github/workflows/7x_tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/7x_tests.yml b/.github/workflows/7x_tests.yml index aee138945..f4880f31c 100644 --- a/.github/workflows/7x_tests.yml +++ b/.github/workflows/7x_tests.yml @@ -12,10 +12,11 @@ jobs: env: TEST_ES_SERVER: http://localhost:9200 RAILS_VERSIONS: '6.0,7.0' + QUIET: true strategy: fail-fast: false matrix: - ruby: ['2.7', '3.0'] + ruby: ['3.0'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From c02e8e5d59031920a993db7d80082ed28acc7330 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 8 Oct 2025 09:25:00 +0100 Subject: [PATCH 10/10] test --- elasticsearch-model/gemfiles/6.0.gemfile | 8 ++++---- elasticsearch-model/gemfiles/7.0.gemfile | 1 + .../model/adapters/active_record/basic_spec.rb | 4 ---- .../spec/elasticsearch/model/adapters/mongoid_spec.rb | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/elasticsearch-model/gemfiles/6.0.gemfile b/elasticsearch-model/gemfiles/6.0.gemfile index 306b16802..8e87589a4 100644 --- a/elasticsearch-model/gemfiles/6.0.gemfile +++ b/elasticsearch-model/gemfiles/6.0.gemfile @@ -24,12 +24,12 @@ source 'https://rubygems.org' gemspec path: '../' -gem 'activemodel', '6.0' -gem 'activerecord', '6.0' -gem 'activesupport', '6.0' +gem 'activemodel', '~> 6.0' +gem 'activerecord', '~> 6.0' +gem 'activesupport', '~> 6.0' group :development, :testing do gem 'pry-nav' gem 'rspec' - gem 'sqlite3' + gem 'sqlite3', '~> 1.4' end diff --git a/elasticsearch-model/gemfiles/7.0.gemfile b/elasticsearch-model/gemfiles/7.0.gemfile index c7de126fe..0c6844d78 100644 --- a/elasticsearch-model/gemfiles/7.0.gemfile +++ b/elasticsearch-model/gemfiles/7.0.gemfile @@ -31,4 +31,5 @@ gem 'activesupport', '7.0' group :development, :testing do gem 'pry-nav' gem 'rspec' + gem 'sqlite3', '~> 2.0' end diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb index a769b38f6..6599f099b 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb @@ -18,9 +18,7 @@ require 'spec_helper' describe Elasticsearch::Model::Adapter::ActiveRecord do - context 'when a document_type is not defined for the Model' do - before do ActiveRecord::Schema.define(:version => 1) do create_table :article_no_types do |t| @@ -42,7 +40,6 @@ end describe 'indexing a document' do - let(:search_result) do ArticleNoType.search('title:test') end @@ -55,7 +52,6 @@ end context 'when a document_type is defined for the Model' do - before(:all) do ActiveRecord::Schema.define(:version => 1) do create_table :articles do |t| diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid_spec.rb index 81a286c0d..71f1fb8d5 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid_spec.rb @@ -163,7 +163,7 @@ class DummyClassForMongoid; end context 'query criteria specified as a proc' do let(:query) do - Proc.new { where(color: "red") } + Proc.new { where({ color: "red" }) } end it 'execites the query' do