notifiable-rails 0.22.1 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/notifiable/app.rb +9 -0
- data/lib/notifiable/notification.rb +0 -7
- data/lib/notifiable/notifier_base.rb +5 -6
- data/lib/notifiable/version.rb +1 -1
- data/spec/model/notifier_base_spec.rb +9 -6
- data/spec/test_app/log/test.log +19333 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8866068be795e5ab4b9eeaca25bd7a32652a7aaa
|
4
|
+
data.tar.gz: 43335737e5ce55937010d5e596ca3c236845e019
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8185060efd46e0014da52f7108a73774532b21fa387cb3d8a1f811ecf444e80f7dc2f590c9d3715fc82816be609686ceba5a5e94dc2ad20aae0efda66e513e70
|
7
|
+
data.tar.gz: 3cd022e2dd580c5db9a9ae8f130b7ba37401044bce353dd524bf8212124815f63c7592dcbc85a966cd5a0a058fbd43ba5ba3c57ea2868b0ff496d5255b966349
|
data/lib/notifiable/app.rb
CHANGED
@@ -10,5 +10,14 @@ module Notifiable
|
|
10
10
|
|
11
11
|
self.configuration[provider].each_pair {|key, value| notifier.send("#{key}=", value) if notifier.methods.include?("#{key}=".to_sym) }
|
12
12
|
end
|
13
|
+
|
14
|
+
def save_notification_statuses?
|
15
|
+
self.configuration[:save_notification_statuses].nil? ? true : self.configuration[:save_notification_statuses]
|
16
|
+
end
|
17
|
+
|
18
|
+
def save_notification_statuses=(save_notification_statuses)
|
19
|
+
self.configuration[:save_notification_statuses] = save_notification_statuses
|
20
|
+
end
|
21
|
+
|
13
22
|
end
|
14
23
|
end
|
@@ -42,12 +42,6 @@ module Notifiable
|
|
42
42
|
notifiers[provider].send_notification(d) if d.is_valid?
|
43
43
|
end
|
44
44
|
|
45
|
-
def summarise
|
46
|
-
self.sent_count = self.notification_statuses.count
|
47
|
-
self.gateway_accepted_count = self.notification_statuses.where(:status => 0).count
|
48
|
-
self.save
|
49
|
-
end
|
50
|
-
|
51
45
|
private
|
52
46
|
def notifiers
|
53
47
|
@notifiers ||= {}
|
@@ -56,7 +50,6 @@ module Notifiable
|
|
56
50
|
def close
|
57
51
|
notifiers.each_value {|n| n.close}
|
58
52
|
@notifiers = nil
|
59
|
-
summarise
|
60
53
|
end
|
61
54
|
end
|
62
55
|
end
|
@@ -31,14 +31,14 @@ module Notifiable
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def processed(device_token, status)
|
34
|
-
if
|
34
|
+
if @notification.app.save_notification_statuses?
|
35
35
|
receipts << {localized_notification_id: self.localized_notification(device_token).id, device_token_id: device_token.id, status: status, created_at: DateTime.now}
|
36
|
-
|
37
36
|
save_receipts if receipts.count >= Notifiable.notification_status_batch_size
|
38
|
-
else
|
39
|
-
@notification.sent_count += 1
|
40
|
-
@notification.save if (@notification.sent_count % Notifiable.notification_status_batch_size == 0)
|
41
37
|
end
|
38
|
+
|
39
|
+
@notification.sent_count += 1
|
40
|
+
@notification.gateway_accepted_count += 1 if status == 0
|
41
|
+
@notification.save if (@notification.sent_count % Notifiable.notification_status_batch_size == 0)
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_env?
|
@@ -53,7 +53,6 @@ module Notifiable
|
|
53
53
|
def save_receipts
|
54
54
|
Notifiable::NotificationStatus.bulk_insert! receipts
|
55
55
|
@receipts = []
|
56
|
-
@notification.summarise
|
57
56
|
end
|
58
57
|
end
|
59
58
|
end
|
data/lib/notifiable/version.rb
CHANGED
@@ -13,7 +13,6 @@ describe Notifiable::NotifierBase do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#processed" do
|
16
|
-
let(:notifiable_app) { FactoryGirl.create(:app, :configuration => {:configurable_mock => {:use_sandbox => true}}) }
|
17
16
|
let(:notification) { FactoryGirl.create(:notification_with_en_localization, :app => notifiable_app) }
|
18
17
|
|
19
18
|
let(:device_token1) { FactoryGirl.create(:device_token, :app => notifiable_app, :locale => 'en') }
|
@@ -24,8 +23,12 @@ describe Notifiable::NotifierBase do
|
|
24
23
|
|
25
24
|
before(:each) { Notifiable.notification_status_batch_size = 2 }
|
26
25
|
|
27
|
-
context "saving receipts" do
|
28
|
-
|
26
|
+
context "saving receipts by default" do
|
27
|
+
let(:notifiable_app) { FactoryGirl.create(:app, :configuration => {:configurable_mock => {:use_sandbox => true}}) }
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
notifiable_app.save_notification_statuses = true
|
31
|
+
|
29
32
|
notifier.processed(device_token1, 0)
|
30
33
|
notifier.processed(device_token2, 0)
|
31
34
|
end
|
@@ -34,10 +37,10 @@ describe Notifiable::NotifierBase do
|
|
34
37
|
it { expect(Notifiable::Notification.first.sent_count).to eq 2 }
|
35
38
|
end
|
36
39
|
|
37
|
-
context "not saving
|
38
|
-
|
39
|
-
Notifiable.save_receipts = false
|
40
|
+
context "not saving statuses" do
|
41
|
+
let(:notifiable_app) { FactoryGirl.create(:app, :configuration => {:save_notification_statuses => false, :configurable_mock => {:use_sandbox => true}}) }
|
40
42
|
|
43
|
+
before(:each) do
|
41
44
|
notifier.processed(device_token1, 0)
|
42
45
|
notifier.processed(device_token2, 0)
|
43
46
|
end
|