Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/customerio/base_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def request_class(method)
Net::HTTP::Put
when :delete
Net::HTTP::Delete
when :get
Net::HTTP::Get
Comment on lines +75 to +76
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GET request support lacks test coverage. Consider adding a test case in spec/base_client_spec.rb similar to the existing tests for PUT requests, to verify that GET requests work correctly with both authentication methods (site_id/api_key and app_key).

Copilot uses AI. Check for mistakes.
else
raise InvalidRequest.new("Invalid request method #{method.inspect}")
end
Expand Down
22 changes: 22 additions & 0 deletions spec/base_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@ def api_client_request_headers
end
end

describe "GET requests" do
describe "with a site ID and API key" do
it "sends a GET request with basic auth" do
stub_request(:get, api_uri('/some/path')).
with(headers: track_client_request_headers).
to_return(status: 200, body: "", headers: {})

track_client.request(:get, '/some/path', "")
end
end

describe "with an app key" do
it "sends a GET request with bearer token" do
stub_request(:get, api_uri('/some/path')).
with(headers: api_client_request_headers).
to_return(status: 200, body: "", headers: {})

api_client.request(:get, '/some/path', "")
end
end
end

describe "#verify_response" do
it "throws an error when the response isn't between 200 and 300" do
stub_request(:put, api_uri('/some/path')).
Expand Down