mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
Revert "FIX: Use Excon to do its own stubbing"
This reverts commit 80af54460a
.
This commit is contained in:
parent
144b810d0e
commit
f8f1548fd4
2 changed files with 13 additions and 15 deletions
|
@ -28,7 +28,10 @@ describe FinalDestination do
|
||||||
end
|
end
|
||||||
|
|
||||||
def redirect_response(from, dest)
|
def redirect_response(from, dest)
|
||||||
Excon.stub({ method: :head, hostname: from }, { status: 302, headers: { "Location" => dest } })
|
stub_request(:head, from).to_return(
|
||||||
|
status: 302,
|
||||||
|
headers: { "Location" => dest }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fd(url)
|
def fd(url)
|
||||||
|
@ -48,7 +51,7 @@ describe FinalDestination do
|
||||||
|
|
||||||
context "without redirects" do
|
context "without redirects" do
|
||||||
before do
|
before do
|
||||||
Excon.stub({ method: :head, hostname: 'eviltrout.com' }, doc_response)
|
stub_request(:head, "https://eviltrout.com").to_return(doc_response)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the final url" do
|
it "returns the final url" do
|
||||||
|
@ -74,9 +77,9 @@ describe FinalDestination do
|
||||||
|
|
||||||
context "with a couple of redirects" do
|
context "with a couple of redirects" do
|
||||||
before do
|
before do
|
||||||
redirect_response("eviltrout.com", "https://codinghorror.com/blog")
|
redirect_response("https://eviltrout.com", "https://codinghorror.com/blog")
|
||||||
redirect_response("codinghorror.com", "https://discourse.org")
|
redirect_response("https://codinghorror.com/blog", "https://discourse.org")
|
||||||
Excon.stub({ method: :head, hostname: 'discourse.org' }, doc_response)
|
stub_request(:head, "https://discourse.org").to_return(doc_response)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the final url" do
|
it "returns the final url" do
|
||||||
|
@ -89,9 +92,9 @@ describe FinalDestination do
|
||||||
|
|
||||||
context "with too many redirects" do
|
context "with too many redirects" do
|
||||||
before do
|
before do
|
||||||
redirect_response("eviltrout.com", "https://codinghorror.com/blog")
|
redirect_response("https://eviltrout.com", "https://codinghorror.com/blog")
|
||||||
redirect_response("codinghorror.com", "https://discourse.org")
|
redirect_response("https://codinghorror.com/blog", "https://discourse.org")
|
||||||
Excon.stub({ method: :head, hostname: 'discourse.org' }, doc_response)
|
stub_request(:head, "https://discourse.org").to_return(doc_response)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the final url" do
|
it "returns the final url" do
|
||||||
|
@ -104,8 +107,8 @@ describe FinalDestination do
|
||||||
|
|
||||||
context "with a redirect to an internal IP" do
|
context "with a redirect to an internal IP" do
|
||||||
before do
|
before do
|
||||||
redirect_response("eviltrout.com", "https://private-host.com")
|
redirect_response("https://eviltrout.com", "https://private-host.com")
|
||||||
Excon.stub({ method: :head, hostname: 'private-host.com' }, doc_response)
|
stub_request(:head, "https://private-host.com").to_return(doc_response)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the final url" do
|
it "returns the final url" do
|
||||||
|
|
|
@ -124,12 +124,7 @@ Spork.prefork do
|
||||||
Discourse.clear_readonly!
|
Discourse.clear_readonly!
|
||||||
|
|
||||||
I18n.locale = :en
|
I18n.locale = :en
|
||||||
Excon.defaults[:mock] = true
|
|
||||||
end
|
|
||||||
|
|
||||||
config.after(:each) do
|
|
||||||
WebMock.reset!
|
WebMock.reset!
|
||||||
Excon.stubs.clear
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestCurrentUserProvider < Auth::DefaultCurrentUserProvider
|
class TestCurrentUserProvider < Auth::DefaultCurrentUserProvider
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue