Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rubygems/remote_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
18 changes: 18 additions & 0 deletions test/rubygems/test_gem_remote_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down