notifiable-apns-grocer 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/notifiable/apns/grocer/stream.rb +2 -2
- data/lib/notifiable/apns/grocer/version.rb +1 -1
- data/notifiable-apns-grocer.gemspec +1 -1
- data/spec/grocer_spec.rb +11 -7
- data/spec/spec_helper.rb +2 -0
- data/spec/support/db/migrate/20131228225138_create_notifiable_apps.rb +10 -0
- data/spec/support/db/migrate/20131228225139_create_notifiable_device_tokens.rb +7 -1
- data/spec/support/db/migrate/20131228225140_create_notifiable_notifications.rb +15 -4
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d368d8bb3ad9b2822c74da4245e566bf91fedcc5
|
4
|
+
data.tar.gz: d5d275c9d66a826376d7998229d748ee18bf4768
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00f85e6cc2358514bbf0c5f41fbc9ea69eb374e792f1cebdb3b35aa9269be898d442880abce8bab35b0cd7e55286dc42bf07851ed0f2097fc3fff5d7092db020
|
7
|
+
data.tar.gz: 691aa2a24d3dfeda18db6c418e7fb554dfcaa6afc782784c02a13a06699ef35f1b94b0c3faf53abff06c6c3e2cb3a687964541461244d30cba7dc9cdc04e6128
|
@@ -15,12 +15,12 @@ module Notifiable
|
|
15
15
|
end
|
16
16
|
|
17
17
|
protected
|
18
|
-
def enqueue(notification, device_token)
|
18
|
+
def enqueue(notification, device_token, params)
|
19
19
|
|
20
20
|
grocer_notification = ::Grocer::Notification.new(
|
21
21
|
device_token: device_token.token,
|
22
22
|
alert: notification.message,
|
23
|
-
custom:
|
23
|
+
custom: params
|
24
24
|
)
|
25
25
|
|
26
26
|
grocer_pusher.push(grocer_notification) unless Notifiable.delivery_method == :test
|
@@ -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.
|
21
|
+
spec.add_dependency "notifiable-rails", ">=0.12.0"
|
22
22
|
spec.add_dependency "grocer"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
data/spec/grocer_spec.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Notifiable::Apns::Grocer::Stream do
|
4
|
-
|
4
|
+
|
5
|
+
let(:a) { Notifiable::App.create }
|
5
6
|
let(:g) { Notifiable::Apns::Grocer::Stream.new }
|
6
|
-
let(:n) { Notifiable::Notification.create(:message => "Test message") }
|
7
|
-
let(:d) { Notifiable::DeviceToken.create(:token => "ABC123", :provider => :apns) }
|
7
|
+
let(:n) { Notifiable::Notification.create(:message => "Test message", :app => a) }
|
8
|
+
let(:d) { Notifiable::DeviceToken.create(:token => "ABC123", :provider => :apns, :app => a) }
|
8
9
|
let(:u) { User.new(d) }
|
9
10
|
|
10
11
|
it "sends a single grocer notification" do
|
@@ -14,13 +15,14 @@ describe Notifiable::Apns::Grocer::Stream do
|
|
14
15
|
Timeout.timeout(2) {
|
15
16
|
notification = @grocer.notifications.pop
|
16
17
|
notification.alert.should eql "Test message"
|
18
|
+
notification.custom[:notification_id].should == n.id
|
17
19
|
}
|
18
20
|
end
|
19
21
|
|
20
22
|
it "sends a single grocer notification in a batch" do
|
21
23
|
|
22
|
-
Notifiable.batch do |b|
|
23
|
-
b.
|
24
|
+
Notifiable.batch(a) do |b|
|
25
|
+
b.add_notifiable(n, u)
|
24
26
|
end
|
25
27
|
Notifiable::NotificationStatus.count.should == 1
|
26
28
|
Notifiable::NotificationStatus.first.status.should == 0
|
@@ -28,20 +30,22 @@ describe Notifiable::Apns::Grocer::Stream do
|
|
28
30
|
Timeout.timeout(2) {
|
29
31
|
notification = @grocer.notifications.pop
|
30
32
|
notification.alert.should eql "Test message"
|
33
|
+
notification.custom[:notification_id].should == n.id
|
31
34
|
}
|
32
35
|
end
|
33
36
|
|
34
37
|
it "supports custom properties" do
|
35
38
|
n.params = {:flag => true}
|
36
39
|
|
37
|
-
Notifiable.batch do |b|
|
38
|
-
b.
|
40
|
+
Notifiable.batch(a) do |b|
|
41
|
+
b.add_notifiable(n, u)
|
39
42
|
end
|
40
43
|
Notifiable::NotificationStatus.count.should == 1
|
41
44
|
Notifiable::NotificationStatus.first.status.should == 0
|
42
45
|
|
43
46
|
Timeout.timeout(2) {
|
44
47
|
notification = @grocer.notifications.pop
|
48
|
+
notification.custom[:notification_id].should == n.id
|
45
49
|
notification.custom[:flag].should == true
|
46
50
|
}
|
47
51
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -19,6 +19,8 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
19
19
|
db_path = 'spec/support/db/test.sqlite3'
|
20
20
|
DatabaseCleaner.strategy = :truncation
|
21
21
|
|
22
|
+
Rails.logger = Logger.new(STDOUT)
|
23
|
+
|
22
24
|
RSpec.configure do |config|
|
23
25
|
config.mock_with :rspec
|
24
26
|
config.order = "random"
|
@@ -3,12 +3,18 @@ class CreateNotifiableDeviceTokens < ActiveRecord::Migration
|
|
3
3
|
def change
|
4
4
|
create_table :notifiable_device_tokens do |t|
|
5
5
|
t.string :token
|
6
|
-
t.string :user_id
|
7
6
|
t.string :provider
|
7
|
+
t.string :device_id
|
8
8
|
t.boolean :is_valid, :default => true
|
9
|
+
t.integer :user_id
|
10
|
+
t.references :app
|
9
11
|
|
10
12
|
t.timestamps
|
11
13
|
end
|
14
|
+
|
15
|
+
add_index :notifiable_device_tokens, :device_id, :unique => true
|
16
|
+
add_index :notifiable_device_tokens, :token, :unique => true
|
17
|
+
add_index :notifiable_device_tokens, :user_id
|
12
18
|
end
|
13
19
|
|
14
20
|
end
|
@@ -2,12 +2,23 @@ class CreateNotifiableNotifications < ActiveRecord::Migration
|
|
2
2
|
|
3
3
|
def change
|
4
4
|
create_table :notifiable_notifications do |t|
|
5
|
-
t.text :title
|
6
5
|
t.text :message
|
7
6
|
t.text :params
|
8
|
-
t.
|
9
|
-
|
10
|
-
|
7
|
+
t.references :app
|
8
|
+
|
9
|
+
#stats
|
10
|
+
t.integer :sent_count, :default => 0
|
11
|
+
t.integer :gateway_accepted_count, :default => 0
|
12
|
+
t.integer :opened_count, :default => 0
|
13
|
+
|
14
|
+
# APNS - Optional
|
15
|
+
#t.integer :badge
|
16
|
+
#t.text :sound
|
17
|
+
#t.datetime :expiry
|
18
|
+
|
19
|
+
# MPNS - Optional
|
20
|
+
#t.text :title
|
21
|
+
|
11
22
|
t.timestamps
|
12
23
|
end
|
13
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifiable-apns-grocer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.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-
|
12
|
+
date: 2014-03-17 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.
|
20
|
+
version: 0.12.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.
|
27
|
+
version: 0.12.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: grocer
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- notifiable-apns-grocer.gemspec
|
175
175
|
- spec/grocer_spec.rb
|
176
176
|
- spec/spec_helper.rb
|
177
|
+
- spec/support/db/migrate/20131228225138_create_notifiable_apps.rb
|
177
178
|
- spec/support/db/migrate/20131228225139_create_notifiable_device_tokens.rb
|
178
179
|
- spec/support/db/migrate/20131228225140_create_notifiable_notifications.rb
|
179
180
|
- spec/support/db/migrate/20131229104039_create_notifiable_notification_statuses.rb
|
@@ -204,6 +205,7 @@ summary: Plugin to use Grocer for APNS with Notifiable-Rails
|
|
204
205
|
test_files:
|
205
206
|
- spec/grocer_spec.rb
|
206
207
|
- spec/spec_helper.rb
|
208
|
+
- spec/support/db/migrate/20131228225138_create_notifiable_apps.rb
|
207
209
|
- spec/support/db/migrate/20131228225139_create_notifiable_device_tokens.rb
|
208
210
|
- spec/support/db/migrate/20131228225140_create_notifiable_notifications.rb
|
209
211
|
- spec/support/db/migrate/20131229104039_create_notifiable_notification_statuses.rb
|