From c5e95d2bdcae2177ade5cea686bf97dffeed79dd Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 1 Sep 2025 09:49:40 +0100 Subject: [PATCH 1/4] [CI] Updates GitHub Actions --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e2ae0ca8..9d73837d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,6 +6,7 @@ on: pull_request: branches: - main + workflow_dispatch: jobs: tests: env: @@ -14,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - rails: [ '6.1', '7.0', '7.1' ] + rails: ['6.1', '7.0', '7.1'] ruby: ['3.1', '3.2', '3.3'] runs-on: ubuntu-latest steps: From 97c4b44b518666f0fe01a316759b0986edfcf502 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 1 Sep 2025 09:54:12 +0100 Subject: [PATCH 2/4] Unlock sqlite in gemfile --- elasticsearch-rails/Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticsearch-rails/Gemfile b/elasticsearch-rails/Gemfile index 4be2dd01..f51541c7 100644 --- a/elasticsearch-rails/Gemfile +++ b/elasticsearch-rails/Gemfile @@ -32,7 +32,7 @@ group :development, :testing do gem 'pry-nav' gem 'rspec' unless defined?(JRUBY_VERSION) - gem 'sqlite3', '~> 1.4' + gem 'sqlite3' gem 'debug' end end From a43dc7c63afcbbb58c7521c6df268ea1fa54af36 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 1 Sep 2025 11:06:49 +0100 Subject: [PATCH 3/4] Updates logsubscriber color code AR 7.0 --- .../rails/instrumentation/log_subscriber.rb | 4 +--- .../spec/instrumentation/log_subscriber_spec.rb | 14 +++++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb index a9f112f5..5110d002 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb @@ -18,7 +18,6 @@ module Elasticsearch module Rails module Instrumentation - # A log subscriber to attach to Elasticsearch related events # # @see https://github.com/rails/rails/blob/master/activerecord/lib/active_record/log_subscriber.rb @@ -58,10 +57,9 @@ def color_option(bold_value) def new_color_syntax? return @new_color_syntax if defined?(@new_color_syntax) - @new_color_syntax = ::Rails.respond_to?(:gem_version) && ::Rails.gem_version >= '7.1' + @new_color_syntax = ::ActiveSupport.respond_to?(:gem_version) && ::ActiveSupport::gem_version >= '7.1' end end - end end end diff --git a/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb b/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb index 7512f006..736aa265 100644 --- a/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb +++ b/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb @@ -27,27 +27,27 @@ allow(instance).to receive(:logger) { logger } end - describe "#search" do + 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 + 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" } + context 'when ActiveSupport version is older' do + let(:active_support_version) { '7.0.0' } before do - allow(::Rails).to receive(:gem_version) { Gem::Version.new(rails_version) } + allow(::ActiveSupport).to receive(:gem_version) { Gem::Version.new(active_support_version) } end - it "logs the event" do - expect(instance).to receive(:color).with(" execute (1.2ms)", described_class::GREEN, true).and_call_original + it 'logs the event' do + expect(instance).to receive(:color).with(' execute (1.2ms)', described_class::GREEN, true).and_return "\e[1m\e[32m execute (1.2ms)\e[0m" 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 From 9466d216bf7fd0812c3c40ac880953d3de262c0c Mon Sep 17 00:00:00 2001 From: Rafay Qayyum Date: Tue, 4 Mar 2025 19:38:36 +0500 Subject: [PATCH 4/4] Fixed Dup on ES Aggregations --- .../lib/elasticsearch/model/response/aggregations.rb | 2 +- .../spec/elasticsearch/model/response/aggregations_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/response/aggregations.rb b/elasticsearch-model/lib/elasticsearch/model/response/aggregations.rb index 6fc4a8e8..2c00af85 100644 --- a/elasticsearch-model/lib/elasticsearch/model/response/aggregations.rb +++ b/elasticsearch-model/lib/elasticsearch/model/response/aggregations.rb @@ -22,7 +22,7 @@ module Response class Aggregations < HashWrapper disable_warnings if respond_to?(:disable_warnings) - def initialize(attributes={}) + def initialize(attributes={}, options= {}) __redefine_enumerable_methods super(attributes) end diff --git a/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb index 4bfd89ef..2027d3cc 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb @@ -80,4 +80,11 @@ def self.index_name; 'foo'; end expect(aggregations.price.max.value).to eq(99) end end + + describe '#dup' do + + it 'creates a copy of the aggregation' do + expect(aggregations.dup).to eq(aggregations) + end + end end