notifiable-gcm-spacialdb 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 769e2320e360a242641239d21d0d8ef9f64347a8
4
- data.tar.gz: 75dee657c770507b26a88bf887cf8abd47271144
3
+ metadata.gz: 190cc80990665f516754191f47e78b579befc5af
4
+ data.tar.gz: c1c5fe160f08a3594171bc4eb669003df2de0b6d
5
5
  SHA512:
6
- metadata.gz: a022b262371b455923117e8b25f8e9c015711a93f67666f7e2dddaf09c331a2ae6236ce4a35130374fe14ea9d355b5eb56164e285b92c98f67f5412ebac0c9ee
7
- data.tar.gz: 862a3ff8c45544b61bb21be8c35a49b627fc6762c0dee4657dae52c3e977c182c23d541a2e7747025f9971fc0b48662623e649747744e348d6c315c6610e89b2
6
+ metadata.gz: 98dfd2e9814235d051e53a82cf05d0a9c4bb45965c8f86f3d6a38c8b749ed01695be1f56b50310d1cf1ff482ffb872623bf6a2eb4cd3b006c66041dadda8351b
7
+ data.tar.gz: 267e694ca074deb949704fdcf60d4e3e524a3ea2e9c05dce81075f89d168615e6a16c1d03f8cc4be25fece9778c274643f80bbb7837347869bb1a8c4376edcfd
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- notifiable-gcm-spacialdb (0.11.1)
4
+ notifiable-gcm-spacialdb (0.12.0)
5
5
  gcm (~> 0.1.1)
6
- notifiable-core (>= 0.1.3)
6
+ notifiable-core (>= 0.2.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -42,7 +42,7 @@ GEM
42
42
  minitest (5.11.3)
43
43
  multi_json (1.13.1)
44
44
  multi_xml (0.6.0)
45
- notifiable-core (0.1.3)
45
+ notifiable-core (0.2.0)
46
46
  activerecord
47
47
  activerecord-import
48
48
  pg (1.0.0)
@@ -55,17 +55,18 @@ module Notifiable
55
55
  results.each_with_index do |result, i|
56
56
  dt = batch[i]
57
57
 
58
- # Remove the token if it is marked NotRegistered (user deleted the App for example)
59
- if ["InvalidRegistration", "NotRegistered"].include? result["error"]
60
- dt.destroy
61
- # Process canonical IDs
58
+ if result["error"]
59
+ dt.destroy if ["InvalidRegistration", "NotRegistered"].include? result["error"]
60
+ processed(dt, Notifiable::NotificationStatus::REJECTED_STATUS, error_code(result["error"]), result["error"])
61
+ next;
62
+
62
63
  elsif result["registration_id"] && Notifiable::DeviceToken.exists?(:token => result["registration_id"])
63
64
  dt.destroy
64
65
  elsif result["registration_id"]
65
- dt.update_attribute('token', result["registration_id"])
66
+ dt.update_attribute('token', result["registration_id"])
66
67
  end
67
-
68
- processed(dt, error_code(result["error"]), result["error"])
68
+
69
+ processed(dt)
69
70
  end
70
71
 
71
72
  end
@@ -1,7 +1,7 @@
1
1
  module Notifiable
2
2
  module Gcm
3
3
  module Spacialdb
4
- VERSION = "0.11.1"
4
+ VERSION = "0.12.0"
5
5
  end
6
6
  end
7
7
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "notifiable-core", ">= 0.1.3"
21
+ spec.add_dependency "notifiable-core", ">= 0.2.0"
22
22
  spec.add_dependency "gcm", '~> 0.1.1'
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
data/spec/batch_spec.rb CHANGED
@@ -18,20 +18,23 @@ describe Notifiable::Gcm::Spacialdb::Batch do
18
18
  let(:request_body) { "{\"registration_ids\":[\"ABC123\"],\"data\":{\"message\":\"Test message\",\"title\":\"Test title\",\"flag\":true,\"n_id\":#{n1.id}}}" }
19
19
  let(:response_body) { '{ "multicast_id": 108, "success": 1, "failure": 0, "canonical_ids": 0, "results": [{ "message_id": "1:08" }]}' }
20
20
  it { expect(Notifiable::NotificationStatus.count).to eq 1 }
21
- it { expect(Notifiable::NotificationStatus.first.status).to eq 0 }
21
+ it { expect(Notifiable::NotificationStatus.first.status).to eq Notifiable::NotificationStatus::SENT_STATUS }
22
22
  end
23
23
 
24
24
  context 'custom attributes' do
25
25
  let(:request_body) { "{\"registration_ids\":[\"ABC123\"],\"data\":{\"message\":\"Test message\",\"flag\":true,\"n_id\":#{n1.id}}}" }
26
26
  let(:response_body) { '{ "multicast_id": 108, "success": 1, "failure": 0, "canonical_ids": 0, "results": [{ "message_id": "1:08" }]}' }
27
27
  it { expect(Notifiable::NotificationStatus.count).to eq 1 }
28
- it { expect(Notifiable::NotificationStatus.first.status).to eq 0 }
28
+ it { expect(Notifiable::NotificationStatus.first.status).to eq Notifiable::NotificationStatus::SENT_STATUS }
29
29
  end
30
30
 
31
31
  context 'deletes an unregistered token' do
32
32
  let(:request_body) { "{\"registration_ids\":[\"ABC123\"],\"data\":{\"message\":\"Test message\",\"flag\":true,\"n_id\":#{n1.id}}}" }
33
33
  let(:response_body) { '{ "multicast_id": 108, "success": 0, "failure": 1, "canonical_ids": 0, "results": [{ "error": "NotRegistered" }]}' }
34
34
  it { expect(Notifiable::NotificationStatus.count).to eq 1 }
35
+ it { expect(Notifiable::NotificationStatus.first.status).to eq Notifiable::NotificationStatus::REJECTED_STATUS }
36
+ it { expect(Notifiable::NotificationStatus.first.error_code).to eq 4 }
37
+ it { expect(Notifiable::NotificationStatus.first.error_message).to eq 'NotRegistered' }
35
38
  it { expect(Notifiable::DeviceToken.count).to eq 0 }
36
39
  end
37
40
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifiable-gcm-spacialdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kamil Kocemba
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-08-26 00:00:00.000000000 Z
12
+ date: 2018-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: notifiable-core
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 0.1.3
20
+ version: 0.2.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 0.1.3
27
+ version: 0.2.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: gcm
30
30
  requirement: !ruby/object:Gem::Requirement