diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index 01788a6a5f17..8f5321847d0d 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -173,7 +173,7 @@ def download(spec, source_uri, install_dir = Gem.dir) end verbose "Using local gem #{local_gem_path}" - when nil then # TODO: test for local overriding cache + when nil then source_path = if Gem.win_platform? && source_uri.scheme && !source_uri.path.include?(":") "#{source_uri.scheme}:#{source_uri.path}" diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb index 5c1d89fad693..ca6cb268fe6f 100644 --- a/test/rubygems/test_gem_remote_fetcher.rb +++ b/test/rubygems/test_gem_remote_fetcher.rb @@ -218,6 +218,24 @@ def test_download_local assert_equal @a1.cache_file, inst.download(@a1, local_path) end + def test_download_from_local_source_overrides_cache + omit "doesn't work if tempdir has +" if @tempdir.include?("+") + + cache_path = @a1.cache_file + FileUtils.mkdir_p File.dirname(cache_path) + File.binwrite(cache_path, "outdated cache") + + local_path = File.join(@tempdir, @a1.file_name) + FileUtils.cp(@a1_gem, local_path) + + fetcher = Gem::RemoteFetcher.fetcher + + stale_cache = File.binread(cache_path) + assert_equal cache_path, fetcher.download(@a1, local_path) + assert_equal File.binread(local_path), File.binread(cache_path) + refute_equal stale_cache, File.binread(cache_path) + end + def test_download_local_space omit "doesn't work if tempdir has +" if @tempdir.include?("+") space_path = File.join @tempdir, "space path"