notifiable-gcm-spacialdb 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/notifiable/gcm/spacialdb/batch.rb +1 -1
- data/lib/notifiable/gcm/spacialdb/version.rb +1 -1
- data/spec/batch_spec.rb +10 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ca653ef7b121212b7ef6166bc468c67d1f70fab
|
4
|
+
data.tar.gz: e8f7631fc7b04beaae5f43067259337dcd92342a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a56b0ca6d4da22e6d01da55caf45687ec61004dd702e0025e0cb55208441be156ea50217cabb9b6458e4227fbc17570c8206706d9b4c7ed8f020b64e41e866e
|
7
|
+
data.tar.gz: be6d20ec97b18b811b458e7410c1275298cc522b02f9c7be683cbe101bd4b0db40ad0828301aa60c64248cc86ac42179a7e71f6e1dd029c58af48b6cc99ae648
|
data/Gemfile.lock
CHANGED
@@ -37,7 +37,7 @@ module Notifiable
|
|
37
37
|
results = body.fetch("results", [])
|
38
38
|
results.each_with_index do |result, idx|
|
39
39
|
# Remove the token if it is marked NotRegistered (user deleted the App for example)
|
40
|
-
if
|
40
|
+
if ["InvalidRegistration", "NotRegistered"].include? result["error"]
|
41
41
|
device_tokens[idx].update_attribute('is_valid', false)
|
42
42
|
else
|
43
43
|
|
data/spec/batch_spec.rb
CHANGED
@@ -24,7 +24,7 @@ describe Notifiable::Gcm::Spacialdb::Batch do
|
|
24
24
|
Notifiable::NotificationDeviceToken.count.should == 1
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
27
|
+
it "marks a unregistered token as invalid" do
|
28
28
|
stub_request(:post, "https://android.googleapis.com/gcm/send").to_return(:body => '{ "multicast_id": 108, "success": 0, "failure": 1, "canonical_ids": 0, "results": [{ "error": "NotRegistered" }]}')
|
29
29
|
|
30
30
|
Notifiable.batch {|b| b.add(n, u)}
|
@@ -33,6 +33,15 @@ describe Notifiable::Gcm::Spacialdb::Batch do
|
|
33
33
|
d.is_valid.should == false
|
34
34
|
end
|
35
35
|
|
36
|
+
it "marks an invalid token as invalid" do
|
37
|
+
stub_request(:post, "https://android.googleapis.com/gcm/send").to_return(:body => '{ "multicast_id": 108, "success": 0, "failure": 1, "canonical_ids": 0, "results": [{ "error": "InvalidRegistration" }]}')
|
38
|
+
|
39
|
+
Notifiable.batch {|b| b.add(n, u)}
|
40
|
+
|
41
|
+
Notifiable::NotificationDeviceToken.count.should == 0
|
42
|
+
d.is_valid.should == false
|
43
|
+
end
|
44
|
+
|
36
45
|
it "updates a token to the canonical ID" do
|
37
46
|
stub_request(:post, "https://android.googleapis.com/gcm/send").to_return(:body => '{ "multicast_id": 108, "success": 1, "failure": 0, "canonical_ids": 1, "results": [{ "message_id": "1:08", "registration_id": "GHJ12345" }]}')
|
38
47
|
|