Permalink
Browse files

Filter prereleases in add_always_install

Now InstallerSet won't incorrectly return prerelease verisons when
the dependency does not request prerelease versions.
  • Loading branch information...
1 parent 0a2ac30 commit 93898249ef9ca82975b5ebfe6b1b6145766f8547 @drbrain drbrain committed Jan 21, 2014
Showing with 15 additions and 0 deletions.
  1. +2 −0 lib/rubygems/resolver/installer_set.rb
  2. +13 −0 test/rubygems/test_gem_resolver_installer_set.rb
@@ -60,6 +60,8 @@ def add_always_install dependency
raise exc
end
+ found.delete_if { |s| s.version.prerelease? } unless dependency.prerelease?
+
newest = found.max_by do |s|
[s.version, s.platform == Gem::Platform::RUBY ? -1 : 1]
end
@@ -37,6 +37,19 @@ def test_add_always_install_errors
refute_empty e.errors
end
+ def test_add_always_install_prerelease
+ spec_fetcher do |fetcher|
+ fetcher.gem 'a', 1
+ fetcher.gem 'a', '3.a'
+ end
+
+ set = Gem::Resolver::InstallerSet.new :both
+
+ set.add_always_install dep('a')
+
+ assert_equal %w[a-1], set.always_install.map { |s| s.full_name }
+ end
+
def test_add_local
a_1, a_1_gem = util_gem 'a', 1

0 comments on commit 9389824

Please sign in to comment.