From 3e8b78d55583bd5ede8017c306164a6cc5c55325 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 16 May 2017 19:05:37 +0300 Subject: [PATCH] Fixed specs for jruby, skip tests for ruby-2.0.0 and add tests for ruby-2.4.0 --- .travis.yml | 14 +++++--------- gemfiles/Gemfile.rails-5.0.rb | 4 ++-- lib/friendly_id/finder_methods.rb | 5 ++++- test/schema.rb | 3 +-- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index fbc49ce9d..2fc707769 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,10 @@ language: ruby cache: bundler rvm: + - 2.4.0 - 2.3.0 - 2.2.0 - 2.1.0 - - 2.0.0 - jruby-9.0.4.0 env: @@ -19,19 +19,15 @@ gemfile: - gemfiles/Gemfile.rails-5.0.rb matrix: - allow_failures: - - rvm: jruby-19mode - gemfile: gemfiles/Gemfile.rails-4.2.rb - env: DB=postgres - - rvm: jruby-9.0.4.0 - gemfile: gemfiles/Gemfile.rails-5.0.rb exclude: - - rvm: 2.0.0 - gemfile: gemfiles/Gemfile.rails-5.0.rb - rvm: 2.1.0 gemfile: gemfiles/Gemfile.rails-5.0.rb - rvm: 2.2.0 gemfile: gemfiles/Gemfile.rails-5.0.rb + - rvm: 2.4.0 + gemfile: gemfiles/Gemfile.rails-4.0.rb + - rvm: 2.4.0 + gemfile: gemfiles/Gemfile.rails-4.1.rb sudo: false diff --git a/gemfiles/Gemfile.rails-5.0.rb b/gemfiles/Gemfile.rails-5.0.rb index abef58b56..c47df9800 100644 --- a/gemfiles/Gemfile.rails-5.0.rb +++ b/gemfiles/Gemfile.rails-5.0.rb @@ -9,8 +9,8 @@ # Database Configuration group :development, :test do platforms :jruby do - gem 'activerecord-jdbcmysql-adapter', '~> 1.3.14' - gem 'activerecord-jdbcpostgresql-adapter', '~> 1.3.14' + gem 'activerecord-jdbcmysql-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter.git', branch: 'rails-5' + gem 'activerecord-jdbcpostgresql-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter.git', branch: 'rails-5' gem 'kramdown' end diff --git a/lib/friendly_id/finder_methods.rb b/lib/friendly_id/finder_methods.rb index e0cf6ebac..2dc6289b2 100644 --- a/lib/friendly_id/finder_methods.rb +++ b/lib/friendly_id/finder_methods.rb @@ -43,7 +43,10 @@ def exists_by_friendly_id?(id) private def potential_primary_key?(id) - case primary_key_type + key_type = primary_key_type + # Hook for "ActiveModel::Type::Integer" instance. + key_type = key_type.type if key_type.respond_to?(:type) + case key_type when :integer Integer(id, 10) rescue false when :uuid diff --git a/test/schema.rb b/test/schema.rb index a7af1cf90..9252ee471 100644 --- a/test/schema.rb +++ b/test/schema.rb @@ -34,7 +34,7 @@ def up slugged_tables.each do |table_name| add_column table_name, :slug, :string - add_index table_name, :slug, :unique => true + add_index table_name, :slug, :unique => true if 'novels' != table_name end scoped_tables.each do |table_name| @@ -44,7 +44,6 @@ def up # This will be used to test scopes add_column :novels, :novelist_id, :integer add_column :novels, :publisher_id, :integer - remove_index :novels, :slug add_index :novels, [:slug, :publisher_id, :novelist_id], :unique => true # This will be used to test column name quoting