Skip to content

Commit 8bca7d0

Browse files
authored
Merge pull request #1056 from gregmolnar/fix_argument_error
Fix argument error
2 parents aada895 + e3f182d commit 8bca7d0

File tree

6 files changed

+19
-13
lines changed

6 files changed

+19
-13
lines changed

.travis.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@ language: ruby
33
sudo: false
44

55
rvm:
6-
- 2.5
6+
- 2.6.0
7+
8+
services:
9+
- mysql
710

811
env:
912
- RAILS=6-0-stable DB=sqlite3
1013
- RAILS=6-0-stable DB=mysql
1114
- RAILS=6-0-stable DB=postgres
1215

16+
- RAILS=v6.0.0 DB=sqlite3
17+
- RAILS=v6.0.0 DB=mysql
18+
- RAILS=v6.0.0 DB=postgres
19+
1320
- RAILS=5-2-stable DB=sqlite3
1421
- RAILS=5-2-stable DB=mysql
1522
- RAILS=5-2-stable DB=postgres

lib/ransack/adapters/active_record/context.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def join_sources
107107
base, joins =
108108
if ::ActiveRecord::VERSION::STRING > Constants::RAILS_5_2_0
109109
alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, @object.table.name, [])
110-
constraints = if ::ActiveRecord::VERSION::STRING >= Constants::RAILS_6_0
110+
constraints = if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_0)
111111
@join_dependency.join_constraints(@object.joins_values, alias_tracker)
112112
else
113113
@join_dependency.join_constraints(@object.joins_values, @join_type, alias_tracker)
@@ -281,7 +281,7 @@ def build_joins(relation)
281281
end
282282
else
283283
alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, relation.table.name, join_list)
284-
join_dependency = if ::ActiveRecord::VERSION::STRING >= Constants::RAILS_6_0
284+
join_dependency = if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_0)
285285
Polyamorous::JoinDependency.new(relation.klass, relation.table, association_joins, Arel::Nodes::OuterJoin)
286286
else
287287
Polyamorous::JoinDependency.new(relation.klass, relation.table, association_joins)
@@ -313,15 +313,15 @@ def find_association(name, parent = @base, klass = nil)
313313
end
314314

315315
def build_association(name, parent = @base, klass = nil)
316-
if ::ActiveRecord::VERSION::STRING >= Constants::RAILS_6_0
316+
if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_0)
317317
jd = Polyamorous::JoinDependency.new(
318318
parent.base_klass,
319319
parent.table,
320320
Polyamorous::Join.new(name, @join_type, klass),
321321
@join_type
322322
)
323323
found_association = jd.instance_variable_get(:@join_root).children.last
324-
elsif ::ActiveRecord::VERSION::STRING < Constants::RAILS_5_2_0
324+
elsif ::Gem::Version.new(::ActiveRecord::VERSION::STRING) < ::Gem::Version.new(Constants::RAILS_5_2_0)
325325
jd = Polyamorous::JoinDependency.new(
326326
parent.base_klass,
327327
Polyamorous::Join.new(name, @join_type, klass),

lib/ransack/constants.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module Constants
4848
RAILS_5_1 = '5.1'.freeze
4949
RAILS_5_2 = '5.2'.freeze
5050
RAILS_5_2_0 = '5.2.0'.freeze
51-
RAILS_6_0 = '6.0.0.rc1'.freeze
51+
RAILS_6_0 = '6.0.0'.freeze
5252

5353
RANSACK_SLASH_SEARCHES = 'ransack/searches'.freeze
5454
RANSACK_SLASH_SEARCHES_SLASH_SEARCH = 'ransack/searches/search'.freeze

polyamorous/lib/polyamorous.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ module Polyamorous
1212
require 'polyamorous/swapping_reflection_class'
1313

1414
ar_version = ::ActiveRecord::VERSION::STRING[0,3]
15-
ar_version = ::ActiveRecord::VERSION::STRING[0,5] if ar_version >= "5.2" && ::ActiveRecord::VERSION::STRING < "6.0"
16-
ar_version = "5.2.1" if ::ActiveRecord::VERSION::STRING >= "5.2.1" && ::ActiveRecord::VERSION::STRING < "6.0"
17-
15+
ar_version = ::ActiveRecord::VERSION::STRING[0,5] if ar_version >= "5.2" && ::ActiveRecord.version < ::Gem::Version.new("6.0")
16+
ar_version = "5.2.1" if ::ActiveRecord::VERSION::STRING >= "5.2.1" && ::ActiveRecord.version < ::Gem::Version.new("6.0")
1817
%w(join_association join_dependency).each do |file|
1918
require "polyamorous/activerecord_#{ar_version}_ruby_2/#{file}"
2019
end

ransack.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
2222
s.add_development_dependency 'rspec', '~> 3'
2323
s.add_development_dependency 'machinist', '~> 1.0.6'
2424
s.add_development_dependency 'faker', '~> 0.9.5'
25-
s.add_development_dependency 'sqlite3', ENV['RAILS'] == '6-0-stable' ? '~> 1.4.1' : '~> 1.3.3'
25+
s.add_development_dependency 'sqlite3', ::Gem::Version.new(ENV['RAILS'].gsub(/^v/, '')) >= ::Gem::Version.new('6-0-stable') ? '~> 1.4.1' : '~> 1.3.3'
2626
s.add_development_dependency 'pg', '~> 0.21'
2727
s.add_development_dependency 'mysql2', '0.3.20'
2828
s.add_development_dependency 'pry', '0.10'

spec/helpers/polyamorous_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ def new_join_association(reflection, children, klass)
33
Polyamorous::JoinAssociation.new reflection, children, klass
44
end
55

6-
if ActiveRecord::VERSION::STRING >= "6.0.0.rc1"
6+
if ActiveRecord.version >= ::Gem::Version.new("6.0.0.rc1")
77
def new_join_dependency(klass, associations = {})
88
Polyamorous::JoinDependency.new klass, klass.arel_table, associations, Polyamorous::InnerJoin
99
end
10-
elsif ActiveRecord::VERSION::STRING > "5.2.0"
10+
elsif ActiveRecord.version > ::Gem::Version.new("5.2.0")
1111
def new_join_dependency(klass, associations = {})
1212
Polyamorous::JoinDependency.new klass, klass.arel_table, associations
1313
end
14-
elsif ActiveRecord::VERSION::STRING == "5.2.0"
14+
elsif ActiveRecord.version == ::Gem::Version.new("5.2.0")
1515
def new_join_dependency(klass, associations = {})
1616
alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(klass.connection, klass.table_name, [])
1717
Polyamorous::JoinDependency.new klass, klass.arel_table, associations, alias_tracker

0 commit comments

Comments
 (0)