File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
lib/article_json/utils/o_embed_resolver
spec/article_json/utlis/o_embed_resolver Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,11 @@ def parsed_api_response
28
28
29
29
# @return [Hash]
30
30
def http_headers
31
- { 'Content-Type' => 'application/json' }
31
+ headers = { 'Content-Type' => 'application/json' }
32
+ unless ArticleJSON . configuration . oembed_user_agent . nil?
33
+ headers [ 'User-Agent' ] = ArticleJSON . configuration . oembed_user_agent
34
+ end
35
+ headers
32
36
end
33
37
34
38
class << self
Original file line number Diff line number Diff line change 22
22
23
23
let ( :oembed_response ) { File . read ( 'spec/fixtures/vimeo_video_oembed.json' ) }
24
24
let ( :expected_headers ) { { 'Content-Type' => 'application/json' } }
25
+ let ( :expected_response ) { JSON . parse ( oembed_response , symbolize_names : 1 ) }
25
26
26
27
before do
27
28
stub_request ( :get , expected_oembed_url )
28
29
. with ( headers : expected_headers )
29
30
. to_return ( body : oembed_response )
30
31
end
31
32
32
- it { should eq JSON . parse ( oembed_response , symbolize_names : true ) }
33
+ context 'with no additional headers' do
34
+ it { should eq expected_response }
35
+ end
36
+
37
+ context 'with additional headers' do
38
+ before { ArticleJSON . configure { |c | c . oembed_user_agent = 'foobar' } }
39
+ let ( :expected_headers ) { super ( ) . merge ( 'User-Agent' => 'foobar' ) }
40
+ it { should eq expected_response }
41
+ end
33
42
end
34
43
end
You can’t perform that action at this time.
0 commit comments