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

Commit

Permalink
Merge pull request #6 from rossjourdain/master
Browse files Browse the repository at this point in the history
Failure on second redirect

Thank you @rossjourdain! ❤️
  • Loading branch information
soulim committed Jul 1, 2016
2 parents ccdf65d + 464ee63 commit ff28a20
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
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

0 comments on commit ff28a20

Please sign in to comment.