Skip to content

Commit

Permalink
Fix Rubocop offences
Browse files Browse the repository at this point in the history
  • Loading branch information
lucascaton committed Nov 8, 2022
1 parent b313ce2 commit b49ec66
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/octokit/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ def parse_query_and_convenience_headers(options)

def response_data_correctly_encoded(response)
# TODO: I'm guessing base64 content responses are still broken, but this fixes the bug we're running into
content_type= response.headers.fetch("content-type", "")
return response.data unless content_type.include?("charset") && response.data.is_a?(String)
content_type = response.headers.fetch('content-type', '')
return response.data unless content_type.include?('charset') && response.data.is_a?(String)

reported_encoding = content_type.match(/charset=([^ ]+)/)[1]
response.data.force_encoding(reported_encoding)
Expand Down
8 changes: 4 additions & 4 deletions spec/octokit/client/contents_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
assert_requested :get, github_url('/repos/octokit/octokit.rb/contents/lib/octokit.rb')
end

it "returns the contents of a file properly encoded as specified by the response headers" do
contents = @client.contents("octokit/octokit.rb", :path => "spec/fixtures/utf8.en.js", accept: "application/vnd.github.V3.raw")
expect(contents).to eq(File.read("spec/fixtures/utf8.en.js"))
it 'returns the contents of a file properly encoded as specified by the response headers' do
contents = @client.contents('octokit/octokit.rb', path: 'spec/fixtures/utf8.en.js', accept: 'application/vnd.github.V3.raw')
expect(contents).to eq(File.read('spec/fixtures/utf8.en.js'))
expect(contents.encoding).to eq(Encoding::UTF_8)
assert_requested :get, github_url("/repos/octokit/octokit.rb/contents/spec/fixtures/utf8.en.js")
assert_requested :get, github_url('/repos/octokit/octokit.rb/contents/spec/fixtures/utf8.en.js')
end
end # .contents

Expand Down

0 comments on commit b49ec66

Please sign in to comment.