Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with get_instance_id_info option params #98

Merged
merged 3 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 1 addition & 3 deletions lib/fcm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@ def send_to_topic(topic, options = {})
end

def get_instance_id_info(iid_token, options = {})
params = {
query: options,
}
params = options

for_uri(INSTANCE_ID_API) do |connection|
response = connection.get("/iid/info/" + iid_token, params)
Expand Down
34 changes: 34 additions & 0 deletions spec/fcm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,40 @@
# TODO
end

describe 'getting instance info' do
Copy link

Choose a reason for hiding this comment

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

Metrics/BlockLength: Block has too many lines. [27/25]

subject(:get_info) { client.get_instance_id_info(registration_id, options) }

let(:options) { nil }
let(:client) { FCM.new("TEST_SERVER_KEY") }
let(:base_uri) { "#{FCM::INSTANCE_ID_API}/iid/info" }
let(:uri) { "#{base_uri}/#{registration_id}" }
let(:mock_request_attributes) do
{ headers: {
'Authorization' => 'key=TEST_SERVER_KEY',
'Content-Type' => 'application/json'
} }
end

context 'without options' do
it 'calls info endpoint' do
endpoint = stub_request(:get, uri).with(mock_request_attributes)
get_info
expect(endpoint).to have_been_requested
end
end

context 'with detail option' do
let(:uri) { "#{base_uri}/#{registration_id}?details=true" }
let(:options) { { details: true } }

it 'calls info endpoint' do
endpoint = stub_request(:get, uri).with(mock_request_attributes)
get_info
expect(endpoint).to have_been_requested
end
end
end

describe "credentials path" do
it "can be a path to a file" do
fcm = FCM.new("test", "README.md")
Expand Down