onebox 1.8.6 → 1.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/onebox.rb +1 -0
- data/lib/onebox/helpers.rb +3 -0
- data/lib/onebox/version.rb +1 -1
- data/spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb +16 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef00f44fb0438b70ec1b8cbe01573eb2ea5601b5
|
4
|
+
data.tar.gz: b6753a95e16de7f6d0a7b47c888d8e7683b48295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4f23e877c9f42bf9fa07d50b93f56fc8955aa22a6bd1a34d3a581c74bc796870024dcc8379689b8bcdccfb34b061d2ffa3f834b79d087f73ab1a75054da5478
|
7
|
+
data.tar.gz: d826e5abd61a33dbcab2cff3ac9af1a50b3a63d40b2151398617ea7b0b56c975509e0bf17f3adac05cc2a5e9bcb3bc4f7671a9a0e0e15366f665530013b7ac37
|
data/lib/onebox.rb
CHANGED
data/lib/onebox/helpers.rb
CHANGED
@@ -19,6 +19,9 @@ module Onebox
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.fetch_response(location, limit=5, domain=nil, headers=nil)
|
22
|
+
|
23
|
+
limit = Onebox.options.redirect_limit if limit > Onebox.options.redirect_limit
|
24
|
+
|
22
25
|
raise Net::HTTPError.new('HTTP redirect too deep', location) if limit == 0
|
23
26
|
|
24
27
|
uri = URI(location)
|
data/lib/onebox/version.rb
CHANGED
@@ -84,10 +84,15 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
describe 'to_html' do
|
87
|
+
after(:each) do
|
88
|
+
Onebox.options = Onebox::DEFAULTS
|
89
|
+
end
|
90
|
+
|
91
|
+
let(:original_link) { "http://www.dailymail.co.uk/pages/live/articles/news/news.html?in_article_id=479146&in_page_id=1770" }
|
92
|
+
let(:redirect_link) { 'http://www.dailymail.co.uk/news/article-479146/Brutality-justice-The-truth-tarred-feathered-drug-dealer.html' }
|
93
|
+
|
87
94
|
before do
|
88
95
|
described_class.whitelist = %w(dailymail.co.uk discourse.org)
|
89
|
-
original_link = "http://www.dailymail.co.uk/pages/live/articles/news/news.html?in_article_id=479146&in_page_id=1770"
|
90
|
-
redirect_link = 'http://www.dailymail.co.uk/news/article-479146/Brutality-justice-The-truth-tarred-feathered-drug-dealer.html'
|
91
96
|
FakeWeb.register_uri(
|
92
97
|
:get,
|
93
98
|
original_link,
|
@@ -95,13 +100,18 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
|
|
95
100
|
location: redirect_link
|
96
101
|
)
|
97
102
|
fake(redirect_link, response('dailymail'))
|
98
|
-
onebox = described_class.new(original_link)
|
99
|
-
@html = onebox.to_html
|
100
103
|
end
|
101
|
-
let(:html) { @html }
|
102
104
|
|
103
105
|
it "follows redirects and includes the summary" do
|
104
|
-
|
106
|
+
Onebox.options = { redirect_limit: 2 }
|
107
|
+
onebox = described_class.new(original_link)
|
108
|
+
expect(onebox.to_html).to include("It was the most chilling image of the week")
|
109
|
+
end
|
110
|
+
|
111
|
+
it "recives an error with too many redirects" do
|
112
|
+
Onebox.options = { redirect_limit: 1 }
|
113
|
+
onebox = described_class.new(original_link)
|
114
|
+
expect(onebox.to_html).to be_nil
|
105
115
|
end
|
106
116
|
end
|
107
117
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onebox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joanna Zeta
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-05-
|
13
|
+
date: 2017-05-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|