Skip to content

Commit 396c918

Browse files
authored
Merge pull request #496 from arashm/fix-faraday-deprecation-errors
Fix faraday deprecation errors for `authorization`
2 parents 86534b5 + d7c5529 commit 396c918

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/zendesk_api/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

spec/core/client_spec.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)