FIX: Use Excon to do its own stubbing
This commit is contained in:
parent
b51126dd5e
commit
80af54460a
|
@ -24,10 +24,7 @@ describe FinalDestination do
|
|||
end
|
||||
|
||||
def redirect_response(from, dest)
|
||||
stub_request(:head, from).to_return(
|
||||
status: 302,
|
||||
headers: { "Location" => dest }
|
||||
)
|
||||
Excon.stub({ method: :head, hostname: from }, { status: 302, headers: { "Location" => dest } })
|
||||
end
|
||||
|
||||
describe '.resolve' do
|
||||
|
@ -43,7 +40,7 @@ describe FinalDestination do
|
|||
|
||||
context "without redirects" do
|
||||
before do
|
||||
stub_request(:head, "https://eviltrout.com").to_return(doc_response)
|
||||
Excon.stub({ method: :head, hostname: 'eviltrout.com' }, doc_response)
|
||||
end
|
||||
|
||||
it "returns the final url" do
|
||||
|
@ -56,9 +53,9 @@ describe FinalDestination do
|
|||
|
||||
context "with a couple of redirects" do
|
||||
before do
|
||||
redirect_response("https://eviltrout.com", "https://codinghorror.com/blog")
|
||||
redirect_response("https://codinghorror.com/blog", "https://discourse.org")
|
||||
stub_request(:head, "https://discourse.org").to_return(doc_response)
|
||||
redirect_response("eviltrout.com", "https://codinghorror.com/blog")
|
||||
redirect_response("codinghorror.com", "https://discourse.org")
|
||||
Excon.stub({ method: :head, hostname: 'discourse.org' }, doc_response)
|
||||
end
|
||||
|
||||
it "returns the final url" do
|
||||
|
@ -71,9 +68,9 @@ describe FinalDestination do
|
|||
|
||||
context "with too many redirects" do
|
||||
before do
|
||||
redirect_response("https://eviltrout.com", "https://codinghorror.com/blog")
|
||||
redirect_response("https://codinghorror.com/blog", "https://discourse.org")
|
||||
stub_request(:head, "https://discourse.org").to_return(doc_response)
|
||||
redirect_response("eviltrout.com", "https://codinghorror.com/blog")
|
||||
redirect_response("codinghorror.com", "https://discourse.org")
|
||||
Excon.stub({ method: :head, hostname: 'discourse.org' }, doc_response)
|
||||
end
|
||||
|
||||
it "returns the final url" do
|
||||
|
@ -86,8 +83,8 @@ describe FinalDestination do
|
|||
|
||||
context "with a redirect to an internal IP" do
|
||||
before do
|
||||
redirect_response("https://eviltrout.com", "https://private-host.com")
|
||||
stub_request(:head, "https://private-host.com").to_return(doc_response)
|
||||
redirect_response("eviltrout.com", "https://private-host.com")
|
||||
Excon.stub({ method: :head, hostname: 'private-host.com' }, doc_response)
|
||||
end
|
||||
|
||||
it "returns the final url" do
|
||||
|
|
|
@ -124,7 +124,12 @@ Spork.prefork do
|
|||
Discourse.clear_readonly!
|
||||
|
||||
I18n.locale = :en
|
||||
Excon.defaults[:mock] = true
|
||||
end
|
||||
|
||||
config.after(:each) do
|
||||
WebMock.reset!
|
||||
Excon.stubs.clear
|
||||
end
|
||||
|
||||
class TestCurrentUserProvider < Auth::DefaultCurrentUserProvider
|
||||
|
|
Loading…
Reference in New Issue