File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ def build_connection
165165
166166 # request
167167 if config . access_token && !config . url_based_access_token
168- builder . authorization ( "Bearer" , config . access_token )
168+ builder . request ( :authorization , "Bearer" , config . access_token )
169169 elsif config . access_token
170170 builder . use ZendeskAPI ::Middleware ::Request ::UrlBasedAccessToken , config . access_token
171171 else
Original file line number Diff line number Diff line change @@ -80,19 +80,22 @@ def url.to_str
8080 end
8181
8282 context "access token" do
83- subject do
84- ZendeskAPI ::Client . new do |config |
83+ before do
84+ @client = ZendeskAPI ::Client . new do |config |
8585 config . url = "https://example.zendesk.com/api/v2"
8686 config . access_token = "hello"
8787 end
88+
89+ stub_request ( :get , %r{/bs$} ) . to_return ( :status => 200 )
8890 end
8991
9092 it "should not build basic auth middleware" do
91- expect ( subject . connection . builder . handlers . index ( Faraday ::Request ::BasicAuthentication ) ) . to be_nil
93+ expect ( @client . connection . builder . handlers . index ( Faraday ::Request ::BasicAuthentication ) ) . to be_nil
9294 end
9395
9496 it "should build token middleware" do
95- expect ( subject . connection . headers [ "Authorization" ] ) . to match ( /Bearer/ )
97+ headers = @client . connection . get ( '/bs' ) . env . request_headers
98+ expect ( headers [ "Authorization" ] ) . to match ( /Bearer/ )
9699 end
97100 end
98101
You can’t perform that action at this time.
0 commit comments