Skip to content

Commit b328a75

Browse files
committed
Fix "retrieve notification key" query
Before, we were sending the wrong parameters to the "retrieve notification key" endpoint. By submitting invalid arguments, we were causing every request to fail. We fixed the query for the "retrieve notification key" endpoint.
1 parent fcf66dc commit b328a75

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

lib/fcm.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ def remove_registration_ids(key_name, project_id, notification_key, registration
8989
alias remove remove_registration_ids
9090

9191
def recover_notification_key(key_name, project_id)
92-
params = {
93-
query: {
94-
notification_key_name: key_name
95-
}
96-
}
92+
params = {notification_key_name: key_name}
9793

9894
extra_headers = {
9995
'project_id' => project_id

spec/fcm_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,25 @@
472472
end # remove context
473473
end
474474

475+
describe "#recover_notification_key" do
476+
it "sends a 'retrieve notification key' request" do
477+
uri = "#{FCM::GROUP_NOTIFICATION_BASE_URI}/gcm/notification"
478+
endpoint = stub_request(:get, uri).with(
479+
headers: {
480+
'Content-Type' => 'application/json',
481+
'Authorization' => "key=TEST_SERVER_KEY",
482+
'project_id' => "TEST_PROJECT_ID"
483+
},
484+
query: {notification_key_name: "TEST_KEY_NAME"}
485+
)
486+
client = FCM.new("TEST_SERVER_KEY")
487+
488+
client.recover_notification_key("TEST_KEY_NAME", "TEST_PROJECT_ID")
489+
490+
expect(endpoint).to have_been_requested
491+
end
492+
end
493+
475494
describe 'subscribing to a topic' do
476495
# TODO
477496
end

0 commit comments

Comments
 (0)