summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Moore <tmoore@incrementalism.net>2015-03-15 14:51:56 +1100
committerTim Moore <tmoore@incrementalism.net>2015-03-15 14:51:56 +1100
commitd80e5f1ffd59821c33a45798232e129f6b1d8899 (patch)
treee935e60ff472d47f006a44093c028d18033236f2
parente73c24660143af961ab7e91675ebc2b55073cca6 (diff)
downloadbundler-d80e5f1ffd59821c33a45798232e129f6b1d8899.tar.gz
Move lookup of mirror into Remote.
-rw-r--r--lib/bundler/fetcher.rb1
-rw-r--r--lib/bundler/source/rubygems/remote.rb1
-rw-r--r--spec/bundler/source/rubygems/remote_spec.rb16
3 files changed, 17 insertions, 1 deletions
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
index bd336a2413..e8d3e36b4c 100644
--- a/lib/bundler/fetcher.rb
+++ b/lib/bundler/fetcher.rb
@@ -397,7 +397,6 @@ module Bundler
private
def configured_uri_for(uri)
- uri = Bundler.settings.mirror_for(uri)
config_auth = Bundler.settings.credentials_for(uri)
Source::Rubygems::Remote.new(uri, config_auth)
end
diff --git a/lib/bundler/source/rubygems/remote.rb b/lib/bundler/source/rubygems/remote.rb
index 1b9854897d..835daf05df 100644
--- a/lib/bundler/source/rubygems/remote.rb
+++ b/lib/bundler/source/rubygems/remote.rb
@@ -6,6 +6,7 @@ module Bundler
:anonymized_uri
def initialize(uri, fallback_auth = nil)
+ uri = Bundler.settings.mirror_for(uri)
@uri = apply_auth(uri, fallback_auth).freeze
@anonymized_uri = remove_auth(@uri).freeze
end
diff --git a/spec/bundler/source/rubygems/remote_spec.rb b/spec/bundler/source/rubygems/remote_spec.rb
index 2421b3c669..a248f43e1d 100644
--- a/spec/bundler/source/rubygems/remote_spec.rb
+++ b/spec/bundler/source/rubygems/remote_spec.rb
@@ -62,4 +62,20 @@ describe Bundler::Source::Rubygems::Remote do
end
end
end
+
+ context "when a mirror with credentials is configured for the URI" do
+ let(:uri) { URI("https://rubygems.org/") }
+ let(:mirror_uri_with_auth) { URI("https://username:password@rubygems-mirror.org/") }
+ let(:mirror_uri_no_auth) { URI("https://rubygems-mirror.org/") }
+
+ before { Bundler.settings["mirror.https://rubygems.org/"] = mirror_uri_with_auth.to_s }
+
+ specify "#uri returns the mirror URI with credentials" do
+ expect(remote(uri).uri).to eq(mirror_uri_with_auth)
+ end
+
+ specify "#anonymized_uri returns the mirror URI without credentials" do
+ expect(remote(uri).anonymized_uri).to eq(mirror_uri_no_auth)
+ end
+ end
end