Skip to content
Draft
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
46 changes: 0 additions & 46 deletions .github/workflows/2.7.yml

This file was deleted.

19 changes: 10 additions & 9 deletions .github/workflows/2.6.yml → .github/workflows/7x_tests.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
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:
TEST_ES_SERVER: http://localhost:9200
RAILS_VERSIONS: '5.0,6.0'
RAILS_VERSIONS: '6.0,7.0'
QUIET: true
strategy:
fail-fast: false
matrix:
ruby: ['3.0']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Increase system limits
run: |
sudo swapoff -a
Expand All @@ -30,11 +31,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
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/jruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: JRuby
on:
push:
branches:
- main
- 7.x
pull_request:
branches:
- main
- 7.x
workflow_dispatch:
branches:
- '*'
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions elasticsearch-model/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -52,6 +51,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
Expand Down
1 change: 0 additions & 1 deletion elasticsearch-model/elasticsearch-model.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
36 changes: 0 additions & 36 deletions elasticsearch-model/gemfiles/4.0.gemfile

This file was deleted.

8 changes: 4 additions & 4 deletions elasticsearch-model/gemfiles/6.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ 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'
gem 'rspec'
gem 'sqlite3', '~> 1.4'
end
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@

# 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' 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'
gem 'sqlite3', '~> 2.0'
end
Original file line number Diff line number Diff line change
Expand Up @@ -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
gem 'rspec'
end
5 changes: 5 additions & 0 deletions elasticsearch-model/lib/elasticsearch/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -42,7 +40,6 @@
end

describe 'indexing a document' do

let(:search_result) do
ArticleNoType.search('title:test')
end
Expand All @@ -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|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions elasticsearch-model/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading
Loading