Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
pull_request:
branches:
- main
workflow_dispatch:
jobs:
tests:
env:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion elasticsearch-rails/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down