onebox 1.8.7 → 1.8.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef00f44fb0438b70ec1b8cbe01573eb2ea5601b5
4
- data.tar.gz: b6753a95e16de7f6d0a7b47c888d8e7683b48295
3
+ metadata.gz: 193a79cfcb0e3461c479883dd4a043c56beb92ad
4
+ data.tar.gz: 8f993f55c01ed4c72957828b08acfe22dee40200
5
5
  SHA512:
6
- metadata.gz: b4f23e877c9f42bf9fa07d50b93f56fc8955aa22a6bd1a34d3a581c74bc796870024dcc8379689b8bcdccfb34b061d2ffa3f834b79d087f73ab1a75054da5478
7
- data.tar.gz: d826e5abd61a33dbcab2cff3ac9af1a50b3a63d40b2151398617ea7b0b56c975509e0bf17f3adac05cc2a5e9bcb3bc4f7671a9a0e0e15366f665530013b7ac37
6
+ metadata.gz: 64b633a02255964ac679fa5a2ca15646d1917d77226a535ef6488360b1f71181ccc9d3499c55d40af1d86b15055d558e365d8d0fce2b52fea9e462b71ad96698
7
+ data.tar.gz: 45084fe78481d3177bcb06a1cbca15f795475b7b4b969af89ddab52cb1209628d81215ea0c361d673515bf95d8feeb78d8b3b32948b05fd5c81d6cbdeb24b08b
@@ -36,6 +36,12 @@ module Onebox
36
36
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
37
37
  end
38
38
 
39
+ headers ||= {}
40
+
41
+ if Onebox.options.user_agent && !headers['User-Agent']
42
+ headers['User-Agent'] = Onebox.options.user_agent
43
+ end
44
+
39
45
  request = Net::HTTP::Get.new(uri.request_uri, headers)
40
46
  start_time = Time.now
41
47
 
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.8.7"
2
+ VERSION = "1.8.8"
3
3
  end
@@ -42,4 +42,32 @@ RSpec.describe Onebox::Helpers do
42
42
  end
43
43
  end
44
44
 
45
+ describe "user_agent" do
46
+ before do
47
+ fake("http://example.com/some-resource", :body => 'test')
48
+ end
49
+
50
+ context "default" do
51
+ it "has the Ruby user agent" do
52
+ described_class.fetch_response('http://example.com/some-resource')
53
+ expect(FakeWeb.last_request.to_hash['user-agent'][0]).to eq("Ruby")
54
+ end
55
+ end
56
+
57
+ context "Custom option" do
58
+ after(:each) do
59
+ Onebox.options = Onebox::DEFAULTS
60
+ end
61
+
62
+ before do
63
+ Onebox.options = { user_agent: "EvilTroutBot v0.1" }
64
+ end
65
+
66
+ it "has the custom user agent" do
67
+ described_class.fetch_response('http://example.com/some-resource')
68
+ expect(FakeWeb.last_request.to_hash['user-agent'][0]).to eq("EvilTroutBot v0.1")
69
+ end
70
+ end
71
+ end
72
+
45
73
  end
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.7
4
+ version: 1.8.8
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-22 00:00:00.000000000 Z
13
+ date: 2017-05-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json