From 7add2a0d5c4b0bd23f3b3d416ba451f22565a8ac Mon Sep 17 00:00:00 2001 From: Lucas Amorim Date: Tue, 13 Oct 2015 19:43:30 -0700 Subject: [PATCH 1/2] Fix specs when running on JRuby. There is a difference in how JRuby and MRI sort_by algorithm works when sorting elements with the same weight. More info: https://github.com/jruby/jruby/issues/3004 Calling #sort! before #sort_by in JRuby appears to make it work just like MRI does. --- lib/lotus/action/mime.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/lotus/action/mime.rb b/lib/lotus/action/mime.rb index 615fa30d..55094f45 100644 --- a/lib/lotus/action/mime.rb +++ b/lib/lotus/action/mime.rb @@ -477,6 +477,9 @@ def best_q_match(q_value_header, available_mimes) # See https://github.com/lotus/controller/issues/104 values = values.reverse unless Lotus::Utils.jruby? + # https://github.com/jruby/jruby/issues/3004 + values.sort! if Lotus::Utils.jruby? + value = values.sort_by do |match, quality| (match.split('/', 2).count('*') * -10) + quality end.last From 0bb6ba37ea8ff155ff73d4af0179a6aec5e2c6e7 Mon Sep 17 00:00:00 2001 From: Lucas Amorim Date: Tue, 13 Oct 2015 23:09:15 -0700 Subject: [PATCH 2/2] Adds JRuby 9.0.1.0 to Travis --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index a1dff2f6..4213e8c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,9 @@ language: ruby sudo: false cache: bundler script: 'bundle exec rake test:coverage --trace' +before_install: + - rvm get head # required by JRuby > 9.0.1.0 + - rvm reload rvm: - 2.0.0 - 2.1.0 @@ -19,6 +22,7 @@ rvm: - rbx-2 - jruby-head - jruby-9000 + - jruby-9.0.1.0 matrix: allow_failures: