File tree Expand file tree Collapse file tree 7 files changed +30
-4
lines changed
lib/elasticsearch/model/adapters Expand file tree Collapse file tree 7 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -8,3 +8,7 @@ coverage/
88rdoc /
99doc /
1010Gemfile.lock
11+
12+ gemfiles /3.0.gemfile.lock
13+ gemfiles /4.0.gemfile.lock
14+ gemfiles /5.0.gemfile.lock
Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ namespace :bundle do
3535 sh "bundle install --gemfile #{ __current__ . join ( 'elasticsearch-model/gemfiles' ) } /3.0.gemfile"
3636 puts '-' *80
3737 sh "bundle install --gemfile #{ __current__ . join ( 'elasticsearch-model/gemfiles' ) } /4.0.gemfile"
38+ puts '-' *80
39+ sh "bundle install --gemfile #{ __current__ . join ( 'elasticsearch-model/gemfiles' ) } /5.0.gemfile"
3840 end
3941
4042 desc "Remove Gemfile.lock in all subprojects"
@@ -45,6 +47,7 @@ namespace :bundle do
4547 end
4648 sh "rm -f #{ __current__ . join ( 'elasticsearch-model/gemfiles' ) } /3.0.gemfile.lock"
4749 sh "rm -f #{ __current__ . join ( 'elasticsearch-model/gemfiles' ) } /4.0.gemfile.lock"
50+ sh "rm -f #{ __current__ . join ( 'elasticsearch-model/gemfiles' ) } /5.0.gemfile.lock"
4851 end
4952end
5053
Original file line number Diff line number Diff line change @@ -28,10 +28,11 @@ namespace :test do
2828 test . test_files = FileList [ "test/integration/**/*_test.rb" ]
2929 end
3030
31- desc "Run integration tests against ActiveModel 3 and 4 "
31+ desc "Run integration tests against ActiveModel 3, 4 and 5 "
3232 task :integration do
3333 sh "BUNDLE_GEMFILE='#{ File . expand_path ( '../gemfiles/3.0.gemfile' , __FILE__ ) } ' bundle exec rake test:run_integration" unless defined? ( RUBY_VERSION ) && RUBY_VERSION > '2.2'
3434 sh "BUNDLE_GEMFILE='#{ File . expand_path ( '../gemfiles/4.0.gemfile' , __FILE__ ) } ' bundle exec rake test:run_integration"
35+ sh "BUNDLE_GEMFILE='#{ File . expand_path ( '../gemfiles/5.0.gemfile' , __FILE__ ) } ' bundle exec rake test:run_integration"
3536 end
3637
3738 desc "Run unit and integration tests"
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ Gem::Specification.new do |s|
3939 s . add_development_dependency "kaminari"
4040 s . add_development_dependency "will_paginate"
4141
42- s . add_development_dependency "minitest" , "~> 4.2"
42+ s . add_development_dependency "minitest" , ">= 4.2"
4343 s . add_development_dependency "test-unit" if defined? ( RUBY_VERSION ) && RUBY_VERSION > '2.2'
4444 s . add_development_dependency "shoulda-context"
4545 s . add_development_dependency "mocha"
Original file line number Diff line number Diff line change 1+ # Usage:
2+ #
3+ # $ BUNDLE_GEMFILE=./gemfiles/5.0.gemfile bundle install
4+ # $ BUNDLE_GEMFILE=./gemfiles/5.0.gemfile bundle exec rake test:integration
5+
6+ source 'https://rubygems.org'
7+
8+ gemspec path: '../'
9+
10+ gem 'activemodel', '~> 5'
11+ gem 'activerecord', '~> 5'
12+ gem 'sqlite3'
Original file line number Diff line number Diff line change @@ -26,7 +26,10 @@ def records
2626 # by redefining `to_a`, unless the user has called `order()`
2727 #
2828 sql_records . instance_exec ( response . response [ 'hits' ] [ 'hits' ] ) do |hits |
29- define_singleton_method :to_a do
29+ ar_records_method_name = :to_a
30+ ar_records_method_name = :records if defined? ( ::ActiveRecord ) && ::ActiveRecord ::VERSION ::MAJOR >= 5
31+
32+ define_singleton_method ( ar_records_method_name ) do
3033 if defined? ( ::ActiveRecord ) && ::ActiveRecord ::VERSION ::MAJOR >= 4
3134 self . load
3235 else
Original file line number Diff line number Diff line change @@ -98,7 +98,10 @@ def as_indexed_json(options = {})
9898 end
9999
100100 should "preserve the search results order for records" do
101- response = Article . search ( 'title:code' )
101+ response = Article . search query : { match : { title : 'code' } } , sort : { clicks : :desc }
102+
103+ assert_equal response . records [ 0 ] . clicks , 3
104+ assert_equal response . records [ 1 ] . clicks , 2
102105
103106 response . records . each_with_hit do |r , h |
104107 assert_equal h . _id , r . id . to_s
You can’t perform that action at this time.
0 commit comments