aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/source/rubygems/remote.rb3
-rw-r--r--spec/bundler/fetcher_spec.rb3
-rw-r--r--spec/bundler/source/rubygems/remote_spec.rb30
3 files changed, 34 insertions, 2 deletions
diff --git a/lib/bundler/source/rubygems/remote.rb b/lib/bundler/source/rubygems/remote.rb
index 561bde19..376ce3ee 100644
--- a/lib/bundler/source/rubygems/remote.rb
+++ b/lib/bundler/source/rubygems/remote.rb
@@ -2,7 +2,7 @@ module Bundler
class Source
class Rubygems
class Remote
- attr_reader :uri, :anonymized_uri, :original_uri
+ attr_reader :uri, :anonymized_uri, :original_uri, :cache_uri
def initialize(uri)
orig_uri = uri
@@ -12,6 +12,7 @@ module Bundler
@uri = apply_auth(uri, fallback_auth).freeze
@anonymized_uri = remove_auth(@uri).freeze
+ @cache_uri = remove_auth(orig_uri.dup).freeze
end
private
diff --git a/spec/bundler/fetcher_spec.rb b/spec/bundler/fetcher_spec.rb
index f1204e7b..0b10371f 100644
--- a/spec/bundler/fetcher_spec.rb
+++ b/spec/bundler/fetcher_spec.rb
@@ -38,8 +38,9 @@ describe Bundler::Fetcher do
context "when a rubygems source mirror is set" do
let(:orig_uri) { URI("http://zombo.com") }
+ let(:cache_uri) { orig_uri.dup.tap {|uri| uri.host = "cache_" + uri.host } }
let(:remote_with_mirror) do
- double("remote", :uri => uri, :original_uri => orig_uri, :anonymized_uri => uri)
+ double("remote", :uri => uri, :original_uri => orig_uri, :anonymized_uri => uri, :cache_uri => cache_uri)
end
let(:fetcher) { Bundler::Fetcher.new(remote_with_mirror) }
diff --git a/spec/bundler/source/rubygems/remote_spec.rb b/spec/bundler/source/rubygems/remote_spec.rb
index 28420774..008af117 100644
--- a/spec/bundler/source/rubygems/remote_spec.rb
+++ b/spec/bundler/source/rubygems/remote_spec.rb
@@ -32,6 +32,17 @@ describe Bundler::Source::Rubygems::Remote do
expect(remote(uri_no_auth).anonymized_uri).to eq(uri_no_auth)
end
end
+
+ describe "#cache_uri" do
+ it "returns the original_uri" do
+ expect(remote(uri_no_auth).cache_uri).to eq(uri_no_auth)
+ end
+
+ it "does not apply given credentials" do
+ Bundler.settings[uri_no_auth.to_s] = credentials
+ expect(remote(uri_no_auth).cache_uri).to eq(uri_no_auth)
+ end
+ end
end
context "when the original URI has a username and password" do
@@ -56,6 +67,17 @@ describe Bundler::Source::Rubygems::Remote do
expect(remote(uri_with_auth).anonymized_uri).to eq(uri_no_auth)
end
end
+
+ describe "#cache_uri" do
+ it "returns the original_uri" do
+ expect(remote(uri_no_auth).cache_uri).to eq(uri_no_auth)
+ end
+
+ it "does not apply given credentials" do
+ Bundler.settings[uri_no_auth.to_s] = credentials
+ expect(remote(uri_no_auth).cache_uri).to eq(uri_no_auth)
+ end
+ end
end
context "when the original URI has only a username" do
@@ -86,6 +108,10 @@ describe Bundler::Source::Rubygems::Remote do
specify "#original_uri returns the original source" do
expect(remote(uri).original_uri).to eq(uri)
end
+
+ specify "#cache_uri returns the original source" do
+ expect(remote(uri).cache_uri).to eq(uri)
+ end
end
context "when a mirror with configured credentials is configured for the URI" do
@@ -109,6 +135,10 @@ describe Bundler::Source::Rubygems::Remote do
specify "#original_uri returns the original source" do
expect(remote(uri).original_uri).to eq(uri)
end
+
+ specify "#cache_uri returns the original source" do
+ expect(remote(uri).cache_uri).to eq(uri)
+ end
end
context "when there is no mirror set" do