notifiable-rails 0.5.1 → 0.6.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: 846bf4cc8b8d7d968ce3f7507d0f16e50024dc53
4
- data.tar.gz: 271e8fe18f6ef3bddceacf3d5837f9f5f4cca5cb
3
+ metadata.gz: 099d66d35755e715b96fbcd6cd5e54896009a483
4
+ data.tar.gz: 24d3b8bb3b7e32576ba54afc03e203b18b3ccc8e
5
5
  SHA512:
6
- metadata.gz: dc8472f2c27ba9786d7cd24459b3136147f42243ce964ed862d3493ed0369f14534a6c6d5ca3d7f8e8dda26bf8774d8e57b050546befa87aab4e818575bee82d
7
- data.tar.gz: a86c11aa3581d0aff7d6bc2fd36eb06d92ac006901ab241fdd9fc6f42395762f1e75ccc1f46c0d27812447abe10660371d82caefdf425115c033753f5ca5f84d
6
+ metadata.gz: fe3ede906fbcf129a02687f48fa98c7497da3e63b614e01f8a9c669d44930ed60477608e1efbae96ba1bb812f942c63731b5b80565b1f826b8f66788ca6f3c2c
7
+ data.tar.gz: 910a181c644904a8bd3126507937108623acb82aec7a91ceb8c508058fa1130efd628bbfa4db9172cd9088a5465833c8b7b01facc207ebc38f85115cea0148a2
@@ -0,0 +1,11 @@
1
+ class CreateNotifiableNotificationStatuses < ActiveRecord::Migration
2
+
3
+ def change
4
+ create_table :notifiable_notification_statuses do |t|
5
+ t.references :notification
6
+ t.references :device_token
7
+ t.integer :status
8
+ end
9
+ end
10
+
11
+ end
@@ -3,6 +3,6 @@ module Notifiable
3
3
 
4
4
  serialize :params
5
5
 
6
- has_many :notification_device_tokens, :class_name => 'Notifiable::NotificationDeviceToken'
6
+ has_many :notification_status, :class_name => 'Notifiable::NotificationStatus'
7
7
  end
8
8
  end
@@ -1,5 +1,5 @@
1
1
  module Notifiable
2
- class NotificationDeviceToken < ActiveRecord::Base
2
+ class NotificationStatus < ActiveRecord::Base
3
3
  belongs_to :notification, :class_name => 'Notifiable::Notification'
4
4
  belongs_to :device_token, :class_name => 'Notifiable::DeviceToken'
5
5
  end
@@ -20,8 +20,8 @@ module Notifiable
20
20
 
21
21
  end
22
22
 
23
- def processed(notification, device_token)
24
- receipts << {:notification_id => notification.id, :device_token_id => device_token.id }
23
+ def processed(notification, device_token, status)
24
+ receipts << {notification_id: notification.id, device_token_id: device_token.id, status: status }
25
25
 
26
26
  if receipts.count > 10000
27
27
  save_receipts
@@ -38,7 +38,7 @@ module Notifiable
38
38
  end
39
39
 
40
40
  def save_receipts
41
- Notifiable::NotificationDeviceToken.bulk_insert! receipts
41
+ Notifiable::NotificationStatus.bulk_insert! receipts
42
42
  @receipts = []
43
43
  end
44
44
  end
@@ -1,3 +1,3 @@
1
1
  module Notifiable
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/notifiable.rb CHANGED
@@ -3,7 +3,7 @@ require 'notifiable/notifiable_concern'
3
3
  require 'notifiable/railtie' if defined?(Rails)
4
4
  require 'notifiable/engine'
5
5
  require 'notifiable/notification'
6
- require 'notifiable/notification_device_token'
6
+ require 'notifiable/notification_status'
7
7
  require 'notifiable/batch'
8
8
  require 'notifiable/device_token'
9
9
  require 'notifiable/notifier_base'
data/spec/batch_spec.rb CHANGED
@@ -22,7 +22,7 @@ class ConfigurableMockNotifier < Notifiable::NotifierBase
22
22
  attr_accessor :use_sandbox
23
23
 
24
24
  def enqueue(notification, device_token)
25
- processed(notification, device_token)
25
+ processed(notification, device_token, 200)
26
26
  end
27
27
  end
28
28
 
@@ -12,9 +12,9 @@ describe Notifiable do
12
12
  b.add(notification1, user2)
13
13
  end
14
14
 
15
- Notifiable::NotificationDeviceToken.count.should == 2
15
+ Notifiable::NotificationStatus.count.should == 2
16
16
 
17
- all_notifications = Notifiable::NotificationDeviceToken.all
17
+ all_notifications = Notifiable::NotificationStatus.all
18
18
  first_notification_token = all_notifications[0]
19
19
  first_notification_token.notification.message.should eql "First test message"
20
20
  first_notification_token.device_token.should eql user1.device_tokens[0]
@@ -30,14 +30,16 @@ describe Notifiable do
30
30
  b.add(notification2, user2)
31
31
  end
32
32
 
33
- Notifiable::NotificationDeviceToken.count.should == 2
33
+ Notifiable::NotificationStatus.count.should == 2
34
34
 
35
- all_notifications = Notifiable::NotificationDeviceToken.all
35
+ all_notifications = Notifiable::NotificationStatus.all
36
36
  first_notification_token = all_notifications[0]
37
+ first_notification_token.status.should == 200
37
38
  first_notification_token.notification.message.should eql "First test message"
38
39
  first_notification_token.device_token.should eql user1.device_tokens[0]
39
40
 
40
41
  second_notification_token = all_notifications[1]
42
+ second_notification_token.status.should == 200
41
43
  second_notification_token.notification.message.should eql "Second test message"
42
44
  second_notification_token.device_token.should eql user2.device_tokens[0]
43
45
  end
@@ -8,7 +8,7 @@ describe Notifiable::Concern do
8
8
 
9
9
  user1.send_notification(notification)
10
10
 
11
- Notifiable::NotificationDeviceToken.count.should == 1
11
+ Notifiable::NotificationStatus.count.should == 1
12
12
  end
13
13
 
14
14
  it "sends zero notifications if the device is not valid" do
@@ -16,7 +16,7 @@ describe Notifiable::Concern do
16
16
 
17
17
  user.send_notification(notification)
18
18
 
19
- Notifiable::NotificationDeviceToken.count.should == 0
19
+ Notifiable::NotificationStatus.count.should == 0
20
20
  end
21
21
 
22
22
  end
data/spec/spec_helper.rb CHANGED
@@ -42,7 +42,7 @@ end
42
42
 
43
43
  class MockNotifier < Notifiable::NotifierBase
44
44
  def enqueue(notification, device_token)
45
- processed(notification, device_token)
45
+ processed(notification, device_token, 200)
46
46
  end
47
47
  end
48
48
 
@@ -0,0 +1,11 @@
1
+ class CreateNotifiableNotificationStatuses < ActiveRecord::Migration
2
+
3
+ def change
4
+ create_table :notifiable_notification_statuses do |t|
5
+ t.references :notification
6
+ t.references :device_token
7
+ t.integer :status
8
+ end
9
+ end
10
+
11
+ end
@@ -27,11 +27,10 @@ ActiveRecord::Schema.define(version: 20131229104039) do
27
27
  add_index "notifiable_device_tokens", ["token"], name: "index_notifiable_device_tokens_on_token", unique: true
28
28
  add_index "notifiable_device_tokens", ["user_id"], name: "index_notifiable_device_tokens_on_user_id"
29
29
 
30
- create_table "notifiable_notification_device_tokens", force: true do |t|
31
- t.integer "notification_id"
32
- t.integer "device_token_id"
33
- t.datetime "created_at"
34
- t.datetime "updated_at"
30
+ create_table "notifiable_notification_statuses", force: true do |t|
31
+ t.integer "notification_id"
32
+ t.integer "device_token_id"
33
+ t.integer "status"
35
34
  end
36
35
 
37
36
  create_table "notifiable_notifications", force: true do |t|
Binary file