notifiable-gcm-spacialdb 0.6.0 → 0.7.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: d4461f897facad949fb42c8202f5d79fc532309d
4
- data.tar.gz: 0061dba421c1b4e99796e702caafdfd94de7d06e
3
+ metadata.gz: bf8617349fad22ba3f960775005a9cf5690f0dc2
4
+ data.tar.gz: b4b074036bedd4eda84de247260f29a7d4fceead
5
5
  SHA512:
6
- metadata.gz: d534b04eb4ce5ffad208c64c7aaa85d988c180fc0d80bfe814cfe7bd316dacd0b5994eb23ec510aa49006bf9eb573791170042367468ff69412a9f3e5861195c
7
- data.tar.gz: 0bab0cb2c5d73aad5e263250127fde6e2f4a6502fb182f100aa6a9841606676edcd4f9a0187c1b8551f8d895bf3abb7c967f84a3a74bf891a73437e70a15000c
6
+ metadata.gz: c9987b8e215fea1e309579aa5311a0a9e86be7df56f2c0f068b0fb57157773bc927ad8bfd342827236e99867b2c32b8f504772c3548368e35b897e91f1de72e9
7
+ data.tar.gz: dff07a33f03b9fe86681a76b490cbb3e535d3cc4bbfab3c2de3803debd5a0f4027da51c0cfd1256bafc3bf0cdccf0cfe1dd9030cbb9c9ff2c8ea3e716328c806
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- notifiable-gcm-spacialdb (0.6.0)
4
+ notifiable-gcm-spacialdb (0.7.0)
5
5
  gcm (~> 0.0.6)
6
- notifiable-rails (>= 0.18.0)
6
+ notifiable-rails (>= 0.19.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -57,7 +57,7 @@ GEM
57
57
  minitest (4.7.5)
58
58
  multi_json (1.8.4)
59
59
  multi_xml (0.5.5)
60
- notifiable-rails (0.18.0)
60
+ notifiable-rails (0.19.0)
61
61
  rails (~> 4.0.0)
62
62
  polyglot (0.3.4)
63
63
  rack (1.5.2)
@@ -51,15 +51,18 @@ module Notifiable
51
51
  results.each_with_index do |result, i|
52
52
  dt = @batch[i]
53
53
 
54
- # Remove the token if it is marked NotRegistered (user deleted the App for example) or is not the canonical ID
55
- if (["InvalidRegistration", "NotRegistered"].include? result["error"]) ||
56
- (result["registration_id"] && Notifiable::DeviceToken.exists?(:token => result["registration_id"]))
57
- dt.destroy
58
- # Update the token if the canonical ID does not exist
59
- else
60
- dt.update_attribute('token', result["registration_id"]) if result["registration_id"]
61
- processed(dt, error_code(result["error"]))
62
- end
54
+ # Remove the token if it is marked NotRegistered (user deleted the App for example)
55
+ if ["InvalidRegistration", "NotRegistered"].include? result["error"]
56
+ dt.update_attribute('is_valid', false)
57
+
58
+ # Process canonical IDs
59
+ elsif result["registration_id"] && Notifiable::DeviceToken.exists?(:token => result["registration_id"])
60
+ dt.update_attribute('is_valid', false)
61
+ elsif result["registration_id"]
62
+ dt.update_attribute('token', result["registration_id"])
63
+ end
64
+
65
+ processed(dt, error_code(result["error"]))
63
66
  end
64
67
  end
65
68
 
@@ -1,7 +1,7 @@
1
1
  module Notifiable
2
2
  module Gcm
3
3
  module Spacialdb
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.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-rails", ">=0.18.0"
21
+ spec.add_dependency "notifiable-rails", ">=0.19.0"
22
22
  spec.add_dependency "gcm", "~> 0.0.6"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
data/spec/batch_spec.rb CHANGED
@@ -31,26 +31,28 @@ describe Notifiable::Gcm::Spacialdb::Batch do
31
31
  Notifiable::NotificationStatus.first.status = 0
32
32
  end
33
33
 
34
- it "delete an unregistered token" do
34
+ it "marks a unregistered token as invalid" do
35
35
  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" }]}')
36
36
 
37
37
  n1.batch do |n|
38
38
  n.add_device_token(d)
39
39
  end
40
40
 
41
- Notifiable::DeviceToken.count == 0
42
- Notifiable::NotificationStatus.count.should == 0
41
+ Notifiable::NotificationStatus.count.should == 1
42
+ Notifiable::NotificationStatus.first.status = 4
43
+ d.is_valid.should == false
43
44
  end
44
45
 
45
- it "delete an invalid token" do
46
+ it "marks an invalid token as invalid" do
46
47
  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" }]}')
47
48
 
48
49
  n1.batch do |n|
49
50
  n.add_device_token(d)
50
51
  end
51
52
 
52
- Notifiable::DeviceToken.count == 0
53
- Notifiable::NotificationStatus.count.should == 0
53
+ Notifiable::NotificationStatus.count.should == 1
54
+ Notifiable::NotificationStatus.first.status = 2
55
+ d.is_valid.should == false
54
56
  end
55
57
 
56
58
  it "updates a token to the canonical ID if it does not exist" do
@@ -5,6 +5,7 @@ class CreateNotifiableDeviceTokens < ActiveRecord::Migration
5
5
  t.string :token
6
6
  t.string :provider
7
7
  t.string :device_id
8
+ t.boolean :is_valid, :default => true
8
9
  t.integer :user_id
9
10
  t.references :app
10
11
 
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.6.0
4
+ version: 0.7.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: 2014-05-08 00:00:00.000000000 Z
12
+ date: 2014-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: notifiable-rails
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '>='
19
19
  - !ruby/object:Gem::Version
20
- version: 0.18.0
20
+ version: 0.19.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.18.0
27
+ version: 0.19.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: gcm
30
30
  requirement: !ruby/object:Gem::Requirement