rpush 2.3.1-java → 2.3.2-java
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/CHANGELOG.md +6 -0
- data/README.md +36 -28
- data/lib/rpush/configuration.rb +1 -0
- data/lib/rpush/daemon/feeder.rb +16 -12
- data/lib/rpush/daemon/interruptible_sleep.rb +26 -5
- data/lib/rpush/daemon/store/active_record.rb +4 -0
- data/lib/rpush/daemon/store/interface.rb +1 -1
- data/lib/rpush/daemon/store/redis.rb +10 -0
- data/lib/rpush/embed.rb +1 -0
- data/lib/rpush/logger.rb +1 -0
- data/lib/rpush/push.rb +1 -2
- data/lib/rpush/version.rb +1 -1
- data/spec/functional/adm_spec.rb +6 -8
- data/spec/functional/apns_spec.rb +9 -9
- data/spec/functional/embed_spec.rb +3 -3
- data/spec/functional/gcm_spec.rb +6 -8
- data/spec/functional/new_app_spec.rb +5 -20
- data/spec/functional/retry_spec.rb +8 -12
- data/spec/functional/synchronization_spec.rb +1 -1
- data/spec/functional/wpns_spec.rb +7 -7
- data/spec/functional_spec_helper.rb +4 -5
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/apns_feedback_spec.rb +4 -4
- data/spec/unit/client/active_record/adm/app_spec.rb +12 -12
- data/spec/unit/client/active_record/adm/notification_spec.rb +9 -9
- data/spec/unit/client/active_record/apns/app_spec.rb +4 -4
- data/spec/unit/client/active_record/apns/feedback_spec.rb +2 -2
- data/spec/unit/client/active_record/apns/notification_spec.rb +46 -46
- data/spec/unit/client/active_record/app_spec.rb +6 -6
- data/spec/unit/client/active_record/gcm/notification_spec.rb +7 -7
- data/spec/unit/client/active_record/notification_spec.rb +2 -2
- data/spec/unit/client/active_record/wpns/notification_spec.rb +2 -8
- data/spec/unit/configuration_spec.rb +5 -5
- data/spec/unit/daemon/adm/delivery_spec.rb +69 -69
- data/spec/unit/daemon/apns/delivery_spec.rb +13 -13
- data/spec/unit/daemon/apns/feedback_receiver_spec.rb +24 -26
- data/spec/unit/daemon/app_runner_spec.rb +29 -29
- data/spec/unit/daemon/batch_spec.rb +30 -30
- data/spec/unit/daemon/delivery_error_spec.rb +2 -2
- data/spec/unit/daemon/delivery_spec.rb +6 -6
- data/spec/unit/daemon/dispatcher/http_spec.rb +5 -5
- data/spec/unit/daemon/dispatcher/tcp_spec.rb +4 -4
- data/spec/unit/daemon/dispatcher_loop_spec.rb +9 -9
- data/spec/unit/daemon/feeder_spec.rb +22 -23
- data/spec/unit/daemon/gcm/delivery_spec.rb +56 -56
- data/spec/unit/daemon/retryable_error_spec.rb +2 -2
- data/spec/unit/daemon/service_config_methods_spec.rb +5 -5
- data/spec/unit/daemon/signal_handler_spec.rb +13 -13
- data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +13 -13
- data/spec/unit/daemon/store/active_record_spec.rb +49 -49
- data/spec/unit/daemon/tcp_connection_spec.rb +50 -50
- data/spec/unit/daemon/wpns/delivery_spec.rb +36 -36
- data/spec/unit/daemon_spec.rb +33 -30
- data/spec/unit/deprecatable_spec.rb +3 -3
- data/spec/unit/deprecation_spec.rb +2 -2
- data/spec/unit/embed_spec.rb +7 -7
- data/spec/unit/logger_spec.rb +25 -25
- data/spec/unit/notification_shared.rb +7 -7
- data/spec/unit/plugin_spec.rb +1 -1
- data/spec/unit/push_spec.rb +8 -8
- data/spec/unit/reflectable_spec.rb +5 -5
- data/spec/unit/reflection_collection_spec.rb +2 -2
- data/spec/unit/rpush_spec.rb +1 -1
- data/spec/unit_spec_helper.rb +4 -5
- metadata +10 -4
@@ -17,16 +17,14 @@ describe Rpush::Daemon::Apns::FeedbackReceiver, 'check_for_feedback' do
|
|
17
17
|
|
18
18
|
before do
|
19
19
|
Rpush.config.feedback_poll = poll
|
20
|
-
Rpush::Daemon::InterruptibleSleep.
|
21
|
-
Rpush.
|
22
|
-
Rpush::Daemon::TcpConnection.
|
20
|
+
allow(Rpush::Daemon::InterruptibleSleep).to receive_messages(new: sleeper)
|
21
|
+
allow(Rpush).to receive_messages(logger: logger)
|
22
|
+
allow(Rpush::Daemon::TcpConnection).to receive_messages(new: connection)
|
23
23
|
receiver.instance_variable_set("@stop", false)
|
24
|
-
Rpush::Daemon.
|
24
|
+
allow(Rpush::Daemon).to receive_messages(store: store)
|
25
25
|
end
|
26
26
|
|
27
27
|
def double_connection_read_with_tuple
|
28
|
-
connection.unstub(:read)
|
29
|
-
|
30
28
|
def connection.read(*)
|
31
29
|
unless @called
|
32
30
|
@called = true
|
@@ -36,78 +34,78 @@ describe Rpush::Daemon::Apns::FeedbackReceiver, 'check_for_feedback' do
|
|
36
34
|
end
|
37
35
|
|
38
36
|
it 'initializes the sleeper with the feedback polling duration' do
|
39
|
-
Rpush::Daemon::InterruptibleSleep.
|
37
|
+
expect(Rpush::Daemon::InterruptibleSleep).to receive(:new).with(poll).and_return(sleeper)
|
40
38
|
Rpush::Daemon::Apns::FeedbackReceiver.new(app)
|
41
39
|
end
|
42
40
|
|
43
41
|
it 'instantiates a new connection' do
|
44
|
-
Rpush::Daemon::TcpConnection.
|
42
|
+
expect(Rpush::Daemon::TcpConnection).to receive(:new).with(app, host, port)
|
45
43
|
receiver.check_for_feedback
|
46
44
|
end
|
47
45
|
|
48
46
|
it 'connects to the feeback service' do
|
49
|
-
connection.
|
47
|
+
expect(connection).to receive(:connect)
|
50
48
|
receiver.check_for_feedback
|
51
49
|
end
|
52
50
|
|
53
51
|
it 'closes the connection' do
|
54
|
-
connection.
|
52
|
+
expect(connection).to receive(:close)
|
55
53
|
receiver.check_for_feedback
|
56
54
|
end
|
57
55
|
|
58
56
|
it 'reads from the connection' do
|
59
|
-
connection.
|
57
|
+
expect(connection).to receive(:read).with(38)
|
60
58
|
receiver.check_for_feedback
|
61
59
|
end
|
62
60
|
|
63
61
|
it 'logs the feedback' do
|
64
62
|
double_connection_read_with_tuple
|
65
|
-
Rpush.logger.
|
63
|
+
expect(Rpush.logger).to receive(:info).with("[my_app] [FeedbackReceiver] Delivery failed at 2011-12-10 16:08:45 UTC for 834f786655eb9f84614a05ad7d00af31e5cfe93ac3ea078f1da44d2a4eb0ce17.")
|
66
64
|
receiver.check_for_feedback
|
67
65
|
end
|
68
66
|
|
69
67
|
it 'creates the feedback' do
|
70
|
-
Rpush::Daemon.store.
|
68
|
+
expect(Rpush::Daemon.store).to receive(:create_apns_feedback).with(Time.at(1_323_533_325), '834f786655eb9f84614a05ad7d00af31e5cfe93ac3ea078f1da44d2a4eb0ce17', app)
|
71
69
|
double_connection_read_with_tuple
|
72
70
|
receiver.check_for_feedback
|
73
71
|
end
|
74
72
|
|
75
73
|
it 'logs errors' do
|
76
74
|
error = StandardError.new('bork!')
|
77
|
-
connection.
|
78
|
-
Rpush.logger.
|
75
|
+
allow(connection).to receive(:read).and_raise(error)
|
76
|
+
expect(Rpush.logger).to receive(:error).with(error)
|
79
77
|
receiver.check_for_feedback
|
80
78
|
end
|
81
79
|
|
82
80
|
describe 'start' do
|
83
81
|
before do
|
84
|
-
Thread.
|
85
|
-
receiver.
|
82
|
+
allow(Thread).to receive(:new).and_yield
|
83
|
+
allow(receiver).to receive(:loop).and_yield
|
86
84
|
end
|
87
85
|
|
88
86
|
it 'sleeps' do
|
89
|
-
receiver.
|
90
|
-
sleeper.
|
87
|
+
allow(receiver).to receive(:check_for_feedback)
|
88
|
+
expect(sleeper).to receive(:sleep).at_least(:once)
|
91
89
|
receiver.start
|
92
90
|
end
|
93
91
|
|
94
92
|
it 'checks for feedback when started' do
|
95
|
-
receiver.
|
93
|
+
expect(receiver).to receive(:check_for_feedback).at_least(:once)
|
96
94
|
receiver.start
|
97
95
|
end
|
98
96
|
end
|
99
97
|
|
100
98
|
describe 'stop' do
|
101
99
|
it 'interrupts sleep when stopped' do
|
102
|
-
receiver.
|
103
|
-
sleeper.
|
100
|
+
allow(receiver).to receive(:check_for_feedback)
|
101
|
+
expect(sleeper).to receive(:stop)
|
104
102
|
receiver.stop
|
105
103
|
end
|
106
104
|
|
107
105
|
it 'releases the store connection' do
|
108
|
-
Thread.
|
109
|
-
receiver.
|
110
|
-
Rpush::Daemon.store.
|
106
|
+
allow(Thread).to receive(:new).and_yield
|
107
|
+
allow(receiver).to receive(:loop).and_yield
|
108
|
+
expect(Rpush::Daemon.store).to receive(:release_connection)
|
111
109
|
receiver.start
|
112
110
|
receiver.stop
|
113
111
|
end
|
@@ -115,7 +113,7 @@ describe Rpush::Daemon::Apns::FeedbackReceiver, 'check_for_feedback' do
|
|
115
113
|
|
116
114
|
it 'reflects feedback was received' do
|
117
115
|
double_connection_read_with_tuple
|
118
|
-
receiver.
|
116
|
+
expect(receiver).to receive(:reflect).with(:apns_feedback, feedback)
|
119
117
|
receiver.check_for_feedback
|
120
118
|
end
|
121
119
|
end
|
@@ -38,16 +38,16 @@ describe Rpush::Daemon::AppRunner, 'enqueue' do
|
|
38
38
|
let(:logger) { double(Rpush::Logger, error: nil, info: nil) }
|
39
39
|
|
40
40
|
before do
|
41
|
-
Rpush.
|
42
|
-
Rpush::Daemon::ProcTitle.
|
43
|
-
Rpush::Daemon::AppRunner.
|
41
|
+
allow(Rpush).to receive_messages(logger: logger)
|
42
|
+
allow(Rpush::Daemon::ProcTitle).to receive(:update)
|
43
|
+
allow(Rpush::Daemon::AppRunner).to receive_messages(new: runner)
|
44
44
|
Rpush::Daemon::AppRunner.start_app(app)
|
45
45
|
end
|
46
46
|
|
47
47
|
after { Rpush::Daemon::AppRunner.stop }
|
48
48
|
|
49
49
|
it 'enqueues notifications on the runner' do
|
50
|
-
runner.
|
50
|
+
expect(runner).to receive(:enqueue).with([notification])
|
51
51
|
Rpush::Daemon::AppRunner.enqueue([notification])
|
52
52
|
end
|
53
53
|
|
@@ -56,7 +56,7 @@ describe Rpush::Daemon::AppRunner, 'enqueue' do
|
|
56
56
|
new_app = double(Rpush::App, id: 3, name: 'NewApp', connections: 1)
|
57
57
|
Rpush::Daemon.store = double(app: new_app)
|
58
58
|
Rpush::Daemon::AppRunner.enqueue([notification])
|
59
|
-
Rpush::Daemon::AppRunner.app_running?(new_app).
|
59
|
+
expect(Rpush::Daemon::AppRunner.app_running?(new_app)).to eq(true)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -66,13 +66,13 @@ describe Rpush::Daemon::AppRunner, 'start_app' do
|
|
66
66
|
let(:logger) { double(Rpush::Logger, error: nil, info: nil) }
|
67
67
|
|
68
68
|
before do
|
69
|
-
Rpush.
|
69
|
+
allow(Rpush).to receive_messages(logger: logger)
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'logs an error if the runner could not be started' do
|
73
|
-
Rpush::Daemon::AppRunner.
|
74
|
-
runner.
|
75
|
-
Rpush.logger.
|
73
|
+
expect(Rpush::Daemon::AppRunner).to receive(:new).with(app).and_return(runner)
|
74
|
+
allow(runner).to receive(:start_dispatchers).and_raise(StandardError)
|
75
|
+
expect(Rpush.logger).to receive(:error)
|
76
76
|
Rpush::Daemon::AppRunner.start_app(app)
|
77
77
|
end
|
78
78
|
end
|
@@ -87,15 +87,15 @@ describe Rpush::Daemon::AppRunner, 'debug' do
|
|
87
87
|
let(:store) { double(all_apps: [app], release_connection: nil) }
|
88
88
|
|
89
89
|
before do
|
90
|
-
Rpush::Daemon.
|
91
|
-
Rpush.
|
90
|
+
allow(Rpush::Daemon).to receive_messages(config: {}, store: store)
|
91
|
+
allow(Rpush).to receive_messages(logger: logger)
|
92
92
|
Rpush::Daemon::AppRunner.start_app(app)
|
93
93
|
end
|
94
94
|
|
95
95
|
after { Rpush::Daemon::AppRunner.stop_app(app.id) }
|
96
96
|
|
97
97
|
it 'prints debug app states to the log' do
|
98
|
-
Rpush.logger.
|
98
|
+
expect(Rpush.logger).to receive(:info).with(kind_of(String))
|
99
99
|
Rpush::Daemon::AppRunner.debug
|
100
100
|
end
|
101
101
|
end
|
@@ -114,27 +114,27 @@ describe Rpush::Daemon::AppRunner do
|
|
114
114
|
let(:store) { double(Rpush::Daemon::Store::ActiveRecord, release_connection: nil) }
|
115
115
|
|
116
116
|
before do
|
117
|
-
Rpush::Daemon::DispatcherLoop.
|
118
|
-
Rpush::Daemon.
|
119
|
-
Rpush::Daemon::AppRunnerSpecService::ServiceLoop.
|
120
|
-
Queue.
|
121
|
-
Rpush.
|
117
|
+
allow(Rpush::Daemon::DispatcherLoop).to receive_messages(new: dispatcher_loop)
|
118
|
+
allow(Rpush::Daemon).to receive_messages(store: store)
|
119
|
+
allow(Rpush::Daemon::AppRunnerSpecService::ServiceLoop).to receive_messages(new: service_loop)
|
120
|
+
allow(Queue).to receive_messages(new: queue)
|
121
|
+
allow(Rpush).to receive_messages(logger: logger)
|
122
122
|
end
|
123
123
|
|
124
124
|
describe 'start' do
|
125
125
|
it 'starts a delivery dispatcher for each connection' do
|
126
|
-
app.
|
126
|
+
allow(app).to receive_messages(connections: 2)
|
127
127
|
runner.start_dispatchers
|
128
|
-
runner.num_dispatcher_loops.
|
128
|
+
expect(runner.num_dispatcher_loops).to eq 2
|
129
129
|
end
|
130
130
|
|
131
131
|
it 'starts the dispatcher loop' do
|
132
|
-
dispatcher_loop.
|
132
|
+
expect(dispatcher_loop).to receive(:start)
|
133
133
|
runner.start_dispatchers
|
134
134
|
end
|
135
135
|
|
136
136
|
it 'starts the loops' do
|
137
|
-
service_loop.
|
137
|
+
expect(service_loop).to receive(:start)
|
138
138
|
runner.start_loops
|
139
139
|
end
|
140
140
|
end
|
@@ -143,27 +143,27 @@ describe Rpush::Daemon::AppRunner do
|
|
143
143
|
let(:notification) { double }
|
144
144
|
|
145
145
|
it 'enqueues the batch' do
|
146
|
-
queue.
|
147
|
-
queue_payload.notification.
|
148
|
-
queue_payload.batch.
|
146
|
+
expect(queue).to receive(:push) do |queue_payload|
|
147
|
+
expect(queue_payload.notification).to eq notification
|
148
|
+
expect(queue_payload.batch).not_to be_nil
|
149
149
|
end
|
150
150
|
runner.enqueue([notification])
|
151
151
|
end
|
152
152
|
|
153
153
|
it 'reflects the notification has been enqueued' do
|
154
|
-
runner.
|
154
|
+
expect(runner).to receive(:reflect).with(:notification_enqueued, notification)
|
155
155
|
runner.enqueue([notification])
|
156
156
|
end
|
157
157
|
|
158
158
|
describe 'a service that batches deliveries' do
|
159
159
|
before do
|
160
|
-
runner.send(:service).
|
160
|
+
allow(runner.send(:service)).to receive_messages(batch_deliveries?: true)
|
161
161
|
end
|
162
162
|
|
163
163
|
describe '1 notification with more than one dispatcher loop' do
|
164
164
|
it 'does not raise ArgumentError: invalid slice size' do
|
165
165
|
# https://github.com/rpush/rpush/issues/57
|
166
|
-
runner.
|
166
|
+
allow(runner).to receive(:num_dispatcher_loops).and_return(2)
|
167
167
|
runner.enqueue([notification])
|
168
168
|
end
|
169
169
|
end
|
@@ -177,12 +177,12 @@ describe Rpush::Daemon::AppRunner do
|
|
177
177
|
end
|
178
178
|
|
179
179
|
it 'stops the delivery dispatchers' do
|
180
|
-
dispatcher_loop.
|
180
|
+
expect(dispatcher_loop).to receive(:stop)
|
181
181
|
runner.stop
|
182
182
|
end
|
183
183
|
|
184
184
|
it 'stop the loops' do
|
185
|
-
service_loop.
|
185
|
+
expect(service_loop).to receive(:stop)
|
186
186
|
runner.stop
|
187
187
|
end
|
188
188
|
end
|
@@ -8,12 +8,12 @@ describe Rpush::Daemon::Batch do
|
|
8
8
|
let(:time) { Time.now }
|
9
9
|
|
10
10
|
before do
|
11
|
-
Time.
|
12
|
-
Rpush::Daemon.
|
11
|
+
allow(Time).to receive_messages(now: time)
|
12
|
+
allow(Rpush::Daemon).to receive_messages(store: store)
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'exposes the number notifications processed' do
|
16
|
-
batch.num_processed.
|
16
|
+
expect(batch.num_processed).to eq 0
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'increments the processed notifications count' do
|
@@ -21,88 +21,88 @@ describe Rpush::Daemon::Batch do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'completes the batch when all notifications have been processed' do
|
24
|
-
batch.
|
24
|
+
expect(batch).to receive(:complete)
|
25
25
|
2.times { batch.notification_processed }
|
26
26
|
end
|
27
27
|
|
28
28
|
describe 'mark_delivered' do
|
29
29
|
it 'marks the notification as delivered immediately without persisting' do
|
30
|
-
store.
|
30
|
+
expect(store).to receive(:mark_delivered).with(notification1, time, persist: false)
|
31
31
|
batch.mark_delivered(notification1)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'defers persisting' do
|
35
35
|
batch.mark_delivered(notification1)
|
36
|
-
batch.delivered.
|
36
|
+
expect(batch.delivered).to eq [notification1]
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
describe 'mark_all_delivered' do
|
41
41
|
it 'marks the notifications as delivered immediately without persisting' do
|
42
|
-
store.
|
43
|
-
store.
|
42
|
+
expect(store).to receive(:mark_delivered).with(notification1, time, persist: false)
|
43
|
+
expect(store).to receive(:mark_delivered).with(notification2, time, persist: false)
|
44
44
|
batch.mark_all_delivered
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'defers persisting' do
|
48
48
|
batch.mark_all_delivered
|
49
|
-
batch.delivered.
|
49
|
+
expect(batch.delivered).to eq [notification1, notification2]
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe 'mark_failed' do
|
54
54
|
it 'marks the notification as failed without persisting' do
|
55
|
-
store.
|
55
|
+
expect(store).to receive(:mark_failed).with(notification1, 1, 'an error', time, persist: false)
|
56
56
|
batch.mark_failed(notification1, 1, 'an error')
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'defers persisting' do
|
60
60
|
batch.mark_failed(notification1, 1, 'an error')
|
61
|
-
batch.failed.
|
61
|
+
expect(batch.failed).to eq([1, 'an error'] => [notification1])
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
describe 'mark_failed' do
|
66
66
|
it 'marks the notification as failed without persisting' do
|
67
|
-
store.
|
68
|
-
store.
|
67
|
+
expect(store).to receive(:mark_failed).with(notification1, 1, 'an error', time, persist: false)
|
68
|
+
expect(store).to receive(:mark_failed).with(notification2, 1, 'an error', time, persist: false)
|
69
69
|
batch.mark_all_failed(1, 'an error')
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'defers persisting' do
|
73
73
|
batch.mark_all_failed(1, 'an error')
|
74
|
-
batch.failed.
|
74
|
+
expect(batch.failed).to eq([1, 'an error'] => [notification1, notification2])
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
describe 'mark_retryable' do
|
79
79
|
it 'marks the notification as retryable without persisting' do
|
80
|
-
store.
|
80
|
+
expect(store).to receive(:mark_retryable).with(notification1, time, persist: false)
|
81
81
|
batch.mark_retryable(notification1, time)
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'defers persisting' do
|
85
85
|
batch.mark_retryable(notification1, time)
|
86
|
-
batch.retryable.
|
86
|
+
expect(batch.retryable).to eq(time => [notification1])
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
describe 'complete' do
|
91
91
|
before do
|
92
|
-
Rpush.
|
93
|
-
batch.
|
92
|
+
allow(Rpush).to receive_messages(logger: double.as_null_object)
|
93
|
+
allow(batch).to receive(:reflect)
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'identifies as complete' do
|
97
97
|
expect do
|
98
98
|
2.times { batch.notification_processed }
|
99
|
-
end.to change(batch, :complete?).to(
|
99
|
+
end.to change(batch, :complete?).to(true)
|
100
100
|
end
|
101
101
|
|
102
102
|
it 'reflects errors raised during completion' do
|
103
103
|
e = StandardError.new
|
104
|
-
batch.
|
105
|
-
batch.
|
104
|
+
allow(batch).to receive(:complete_delivered).and_raise(e)
|
105
|
+
expect(batch).to receive(:reflect).with(:error, e)
|
106
106
|
2.times { batch.notification_processed }
|
107
107
|
end
|
108
108
|
|
@@ -115,13 +115,13 @@ describe Rpush::Daemon::Batch do
|
|
115
115
|
end
|
116
116
|
|
117
117
|
it 'marks the batch as delivered' do
|
118
|
-
store.
|
118
|
+
expect(store).to receive(:mark_batch_delivered).with([notification1, notification2])
|
119
119
|
complete
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'reflects the notifications were delivered' do
|
123
|
-
batch.
|
124
|
-
batch.
|
123
|
+
expect(batch).to receive(:reflect).with(:notification_delivered, notification1)
|
124
|
+
expect(batch).to receive(:reflect).with(:notification_delivered, notification2)
|
125
125
|
complete
|
126
126
|
end
|
127
127
|
end
|
@@ -135,13 +135,13 @@ describe Rpush::Daemon::Batch do
|
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'marks the batch as failed' do
|
138
|
-
store.
|
138
|
+
expect(store).to receive(:mark_batch_failed).with([notification1, notification2], 1, 'an error')
|
139
139
|
complete
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'reflects the notifications failed' do
|
143
|
-
batch.
|
144
|
-
batch.
|
143
|
+
expect(batch).to receive(:reflect).with(:notification_failed, notification1)
|
144
|
+
expect(batch).to receive(:reflect).with(:notification_failed, notification2)
|
145
145
|
complete
|
146
146
|
end
|
147
147
|
end
|
@@ -155,13 +155,13 @@ describe Rpush::Daemon::Batch do
|
|
155
155
|
end
|
156
156
|
|
157
157
|
it 'marks the batch as retryable' do
|
158
|
-
store.
|
158
|
+
expect(store).to receive(:mark_batch_retryable).with([notification1, notification2], time)
|
159
159
|
complete
|
160
160
|
end
|
161
161
|
|
162
162
|
it 'reflects the notifications will be retried' do
|
163
|
-
batch.
|
164
|
-
batch.
|
163
|
+
expect(batch).to receive(:reflect).with(:notification_will_retry, notification1)
|
164
|
+
expect(batch).to receive(:reflect).with(:notification_will_retry, notification2)
|
165
165
|
complete
|
166
166
|
end
|
167
167
|
end
|
@@ -4,10 +4,10 @@ describe Rpush::DeliveryError do
|
|
4
4
|
let(:error) { Rpush::DeliveryError.new(4, 12, "Missing payload") }
|
5
5
|
|
6
6
|
it "returns an informative message" do
|
7
|
-
error.to_s.
|
7
|
+
expect(error.to_s).to eq "Unable to deliver notification 12, received error 4 (Missing payload)"
|
8
8
|
end
|
9
9
|
|
10
10
|
it "returns the error code" do
|
11
|
-
error.code.
|
11
|
+
expect(error.code).to eq 4
|
12
12
|
end
|
13
13
|
end
|