Skip to content
This repository has been archived by the owner on Dec 26, 2019. It is now read-only.

Failure on second redirect #6

Merged
merged 5 commits into from
Jul 1, 2016
Merged
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
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
language: ruby
rvm:
- "1.9.3"
- "2.0"
- "2.1"
- "ruby-head"
- "jruby"
- 1.9.3
- 2.0
- 2.1
- 2.2
- 2.3.0
- ruby-head
- jruby
before_install: gem update bundler
2 changes: 1 addition & 1 deletion lib/oembed/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def establish_connection(host, port)

def follow_redirection(location, limit)
if limit > 0
get(location, limit - 1)
get(location, limit: limit - 1)
else
raise Oembed::RedirectionTooDeepError, 'HTTP redirects too deep'
end
Expand Down
16 changes: 16 additions & 0 deletions spec/oembed/http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@
end
end

context 'when response is a redirect, followed by a redirect' do
let(:redirect_uri_one) { 'http://example.com/redirect_one' }
let(:redirect_uri_two) { 'http://example.com/redirect_two' }

before do
FakeWeb.register_uri(:get, uri, body: 'Redirect', status: [301, 'Moved Permanently'], location: redirect_uri_one)
FakeWeb.register_uri(:get, redirect_uri_one, body: 'Redirect', status: [301, 'Moved Permanently'], location: redirect_uri_two)
FakeWeb.register_uri(:get, redirect_uri_two, body: 'OK', status: [200, 'OK'])
end

it 'should parse response body, eventually' do
expect(parser).to receive(:parse)
subject.get(uri)
end
end

context 'when amount of redirects is above the limit' do
before do
FakeWeb.register_uri(:get, uri, body: 'Redirect', status: [301, 'Moved Permanently'])
Expand Down