rpush 2.3.2-java → 2.4.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +1 -1
- data/lib/generators/rpush_migration_generator.rb +21 -6
- data/lib/generators/templates/rpush.rb +5 -5
- data/lib/generators/templates/rpush_2_0_0_updates.rb +24 -0
- data/lib/rpush/client/active_model/apns/notification.rb +1 -1
- data/lib/rpush/client/mongoid/adm/app.rb +14 -0
- data/lib/rpush/client/mongoid/adm/notification.rb +11 -0
- data/lib/rpush/client/mongoid/apns/app.rb +11 -0
- data/lib/rpush/client/mongoid/apns/feedback.rb +21 -0
- data/lib/rpush/client/mongoid/apns/notification.rb +15 -0
- data/lib/rpush/client/mongoid/app.rb +23 -0
- data/lib/rpush/client/mongoid/gcm/app.rb +11 -0
- data/lib/rpush/client/mongoid/gcm/notification.rb +11 -0
- data/lib/rpush/client/mongoid/notification.rb +43 -0
- data/lib/rpush/client/mongoid/wpns/app.rb +11 -0
- data/lib/rpush/client/mongoid/wpns/notification.rb +11 -0
- data/lib/rpush/client/mongoid.rb +31 -0
- data/lib/rpush/client/redis.rb +2 -2
- data/lib/rpush/configuration.rb +48 -29
- data/lib/rpush/daemon/adm/delivery.rb +1 -1
- data/lib/rpush/daemon/apns/feedback_receiver.rb +2 -3
- data/lib/rpush/daemon/apns.rb +1 -1
- data/lib/rpush/daemon/dispatcher/apns_tcp.rb +2 -1
- data/lib/rpush/daemon/feeder.rb +4 -7
- data/lib/rpush/daemon/gcm/delivery.rb +1 -1
- data/lib/rpush/daemon/interruptible_sleep.rb +5 -50
- data/lib/rpush/daemon/proc_title.rb +2 -1
- data/lib/rpush/daemon/store/active_record.rb +4 -0
- data/lib/rpush/daemon/store/interface.rb +1 -1
- data/lib/rpush/daemon/store/mongoid.rb +157 -0
- data/lib/rpush/daemon/store/redis.rb +6 -2
- data/lib/rpush/deprecatable.rb +1 -2
- data/lib/rpush/deprecation.rb +6 -0
- data/lib/rpush/embed.rb +5 -0
- data/lib/rpush/logger.rb +5 -8
- data/lib/rpush/push.rb +5 -0
- data/lib/rpush/version.rb +1 -1
- data/lib/tasks/quality.rake +1 -1
- data/lib/tasks/test.rake +9 -4
- data/spec/functional/apns_spec.rb +2 -1
- data/spec/functional_spec_helper.rb +2 -2
- data/spec/spec_helper.rb +18 -7
- data/spec/support/config/mongoid.yml +69 -0
- data/spec/support/mongoid_setup.rb +10 -0
- data/spec/unit/client/active_record/adm/app_spec.rb +1 -1
- data/spec/unit/client/active_record/adm/notification_spec.rb +1 -1
- data/spec/unit/client/active_record/apns/app_spec.rb +1 -1
- data/spec/unit/client/active_record/apns/feedback_spec.rb +1 -1
- data/spec/unit/client/active_record/apns/notification_spec.rb +11 -11
- data/spec/unit/client/active_record/app_spec.rb +1 -1
- data/spec/unit/client/active_record/gcm/notification_spec.rb +1 -1
- data/spec/unit/client/active_record/notification_spec.rb +1 -1
- data/spec/unit/client/active_record/wpns/notification_spec.rb +1 -1
- data/spec/unit/configuration_spec.rb +7 -0
- data/spec/unit/daemon/apns/feedback_receiver_spec.rb +5 -5
- data/spec/unit/daemon/feeder_spec.rb +2 -2
- data/spec/unit/daemon/proc_title_spec.rb +11 -0
- data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +1 -1
- data/spec/unit/daemon/store/active_record_spec.rb +21 -12
- data/spec/unit/daemon/store/mongoid_spec.rb +339 -0
- data/spec/unit/daemon/store/redis_spec.rb +365 -0
- data/spec/unit/embed_spec.rb +4 -2
- data/spec/unit/logger_spec.rb +14 -5
- data/spec/unit/notification_shared.rb +1 -1
- data/spec/unit/push_spec.rb +4 -2
- data/spec/unit_spec_helper.rb +3 -3
- metadata +27 -4
@@ -0,0 +1,365 @@
|
|
1
|
+
require 'unit_spec_helper'
|
2
|
+
require 'rpush/daemon/store/redis'
|
3
|
+
|
4
|
+
describe Rpush::Daemon::Store::Redis do
|
5
|
+
let(:app) { Rpush::Client::Redis::Apns::App.create!(name: 'my_app', environment: 'development', certificate: TEST_CERT) }
|
6
|
+
let(:notification) { Rpush::Client::Redis::Apns::Notification.create!(device_token: "a" * 64, app: app) }
|
7
|
+
let(:store) { Rpush::Daemon::Store::Redis.new }
|
8
|
+
let(:time) { Time.now.utc }
|
9
|
+
let(:logger) { double(Rpush::Logger, error: nil, internal_logger: nil) }
|
10
|
+
|
11
|
+
before do
|
12
|
+
allow(Rpush).to receive_messages(logger: logger)
|
13
|
+
allow(Time).to receive_messages(now: time)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'updates an notification' do
|
17
|
+
expect(notification).to receive(:save!)
|
18
|
+
store.update_notification(notification)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'updates an app' do
|
22
|
+
expect(app).to receive(:save!)
|
23
|
+
store.update_app(app)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'finds an app by ID' do
|
27
|
+
app
|
28
|
+
expect(store.app(app.id)).to eq(app)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'finds all apps' do
|
32
|
+
app
|
33
|
+
expect(store.all_apps).to eq([app])
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'translates an Integer notification ID' do
|
37
|
+
expect(store.translate_integer_notification_id(notification.id)).to eq(notification.id)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns the pending notification count' do
|
41
|
+
notification
|
42
|
+
expect(store.pending_delivery_count).to eq(1)
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'deliverable_notifications' do
|
46
|
+
it 'loads notifications in batches' do
|
47
|
+
Rpush.config.batch_size = 100
|
48
|
+
allow(store).to receive_messages(pending_notification_ids: [1, 2, 3, 4])
|
49
|
+
expect(Rpush::Client::Redis::Notification).to receive(:find).exactly(4).times
|
50
|
+
store.deliverable_notifications(Rpush.config.batch_size)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'loads an undelivered notification without deliver_after set' do
|
54
|
+
notification.update_attributes!(delivered: false, deliver_after: nil)
|
55
|
+
expect(store.deliverable_notifications(Rpush.config.batch_size)).to eq [notification]
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'loads an notification with a deliver_after time in the past' do
|
59
|
+
notification.update_attributes!(delivered: false, deliver_after: 1.hour.ago)
|
60
|
+
expect(store.deliverable_notifications(Rpush.config.batch_size)).to eq [notification]
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'does not load an notification with a deliver_after time in the future' do
|
64
|
+
notification
|
65
|
+
notification = store.deliverable_notifications(Rpush.config.batch_size).first
|
66
|
+
store.mark_retryable(notification, 1.hour.from_now)
|
67
|
+
expect(store.deliverable_notifications(Rpush.config.batch_size)).to be_empty
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'does not load a previously delivered notification' do
|
71
|
+
notification
|
72
|
+
notification = store.deliverable_notifications(Rpush.config.batch_size).first
|
73
|
+
store.mark_delivered(notification, Time.now)
|
74
|
+
expect(store.deliverable_notifications(Rpush.config.batch_size)).to be_empty
|
75
|
+
end
|
76
|
+
|
77
|
+
it "does not enqueue a notification that has previously failed delivery" do
|
78
|
+
notification
|
79
|
+
notification = store.deliverable_notifications(Rpush.config.batch_size).first
|
80
|
+
store.mark_failed(notification, 0, "failed", Time.now)
|
81
|
+
expect(store.deliverable_notifications(Rpush.config.batch_size)).to be_empty
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe 'mark_retryable' do
|
86
|
+
it 'increments the retry count' do
|
87
|
+
expect do
|
88
|
+
store.mark_retryable(notification, time)
|
89
|
+
end.to change(notification, :retries).by(1)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'sets the deliver after timestamp' do
|
93
|
+
deliver_after = time + 10.seconds
|
94
|
+
expect do
|
95
|
+
store.mark_retryable(notification, deliver_after)
|
96
|
+
end.to change(notification, :deliver_after).to(deliver_after)
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'saves the notification without validation' do
|
100
|
+
expect(notification).to receive(:save!).with(validate: false)
|
101
|
+
store.mark_retryable(notification, time)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'does not save the notification if persist: false' do
|
105
|
+
expect(notification).not_to receive(:save!)
|
106
|
+
store.mark_retryable(notification, time, persist: false)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe 'mark_ids_retryable' do
|
111
|
+
let(:deliver_after) { time + 10.seconds }
|
112
|
+
|
113
|
+
it 'sets the deliver after timestamp' do
|
114
|
+
expect do
|
115
|
+
store.mark_ids_retryable([notification.id], deliver_after)
|
116
|
+
notification.reload
|
117
|
+
end.to change { notification.deliver_after.try(:utc).to_s }.to(deliver_after.utc.to_s)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe 'mark_batch_retryable' do
|
122
|
+
let(:deliver_after) { time + 10.seconds }
|
123
|
+
|
124
|
+
it 'sets the attributes on the object for use in reflections' do
|
125
|
+
store.mark_batch_retryable([notification], deliver_after)
|
126
|
+
expect(notification.deliver_after).to eq deliver_after
|
127
|
+
expect(notification.retries).to eq 1
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'increments the retired count' do
|
131
|
+
expect do
|
132
|
+
store.mark_batch_retryable([notification], deliver_after)
|
133
|
+
notification.reload
|
134
|
+
end.to change(notification, :retries).by(1)
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'sets the deliver after timestamp' do
|
138
|
+
expect do
|
139
|
+
store.mark_batch_retryable([notification], deliver_after)
|
140
|
+
notification.reload
|
141
|
+
end.to change { notification.deliver_after.try(:utc).to_s }.to(deliver_after.utc.to_s)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe 'mark_delivered' do
|
146
|
+
it 'marks the notification as delivered' do
|
147
|
+
expect do
|
148
|
+
store.mark_delivered(notification, time)
|
149
|
+
end.to change(notification, :delivered).to(true)
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'sets the time the notification was delivered' do
|
153
|
+
expect do
|
154
|
+
store.mark_delivered(notification, time)
|
155
|
+
notification.reload
|
156
|
+
end.to change { notification.delivered_at.try(:utc).to_s }.to(time.to_s)
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'saves the notification without validation' do
|
160
|
+
expect(notification).to receive(:save!).with(validate: false)
|
161
|
+
store.mark_delivered(notification, time)
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'does not save the notification if persist: false' do
|
165
|
+
expect(notification).not_to receive(:save!)
|
166
|
+
store.mark_delivered(notification, time, persist: false)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe 'mark_batch_delivered' do
|
171
|
+
it 'sets the attributes on the object for use in reflections' do
|
172
|
+
store.mark_batch_delivered([notification])
|
173
|
+
expect(notification.delivered_at).to eq time
|
174
|
+
expect(notification.delivered).to be_truthy
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'marks the notifications as delivered' do
|
178
|
+
expect do
|
179
|
+
store.mark_batch_delivered([notification])
|
180
|
+
notification.reload
|
181
|
+
end.to change(notification, :delivered).to(true)
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'sets the time the notifications were delivered' do
|
185
|
+
expect do
|
186
|
+
store.mark_batch_delivered([notification])
|
187
|
+
notification.reload
|
188
|
+
end.to change { notification.delivered_at.try(:utc).to_s }.to(time.to_s)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
describe 'mark_failed' do
|
193
|
+
it 'marks the notification as not delivered' do
|
194
|
+
store.mark_failed(notification, nil, '', time)
|
195
|
+
expect(notification.delivered).to eq(false)
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'marks the notification as failed' do
|
199
|
+
expect do
|
200
|
+
store.mark_failed(notification, nil, '', time)
|
201
|
+
notification.reload
|
202
|
+
end.to change(notification, :failed).to(true)
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'sets the time the notification delivery failed' do
|
206
|
+
expect do
|
207
|
+
store.mark_failed(notification, nil, '', time)
|
208
|
+
notification.reload
|
209
|
+
end.to change { notification.failed_at.try(:utc).to_s }.to(time.to_s)
|
210
|
+
end
|
211
|
+
|
212
|
+
it 'sets the error code' do
|
213
|
+
expect do
|
214
|
+
store.mark_failed(notification, 42, '', time)
|
215
|
+
end.to change(notification, :error_code).to(42)
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'sets the error description' do
|
219
|
+
expect do
|
220
|
+
store.mark_failed(notification, 42, 'Weeee', time)
|
221
|
+
end.to change(notification, :error_description).to('Weeee')
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'saves the notification without validation' do
|
225
|
+
expect(notification).to receive(:save!).with(validate: false)
|
226
|
+
store.mark_failed(notification, nil, '', time)
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'does not save the notification if persist: false' do
|
230
|
+
expect(notification).not_to receive(:save!)
|
231
|
+
store.mark_failed(notification, nil, '', time, persist: false)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe 'mark_ids_failed' do
|
236
|
+
it 'marks the notification as failed' do
|
237
|
+
expect do
|
238
|
+
store.mark_ids_failed([notification.id], nil, '', Time.now)
|
239
|
+
notification.reload
|
240
|
+
end.to change(notification, :failed).to(true)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
describe 'mark_batch_failed' do
|
245
|
+
it 'sets the attributes on the object for use in reflections' do
|
246
|
+
store.mark_batch_failed([notification], 123, 'an error')
|
247
|
+
expect(notification.failed_at).to eq time
|
248
|
+
expect(notification.delivered_at).to be_nil
|
249
|
+
expect(notification.delivered).to eq(false)
|
250
|
+
expect(notification.failed).to be_truthy
|
251
|
+
expect(notification.error_code).to eq 123
|
252
|
+
expect(notification.error_description).to eq 'an error'
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'marks the notification as not delivered' do
|
256
|
+
store.mark_batch_failed([notification], nil, '')
|
257
|
+
notification.reload
|
258
|
+
expect(notification.delivered).to be_falsey
|
259
|
+
end
|
260
|
+
|
261
|
+
it 'marks the notification as failed' do
|
262
|
+
expect do
|
263
|
+
store.mark_batch_failed([notification], nil, '')
|
264
|
+
notification.reload
|
265
|
+
end.to change(notification, :failed).to(true)
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'sets the time the notification delivery failed' do
|
269
|
+
expect do
|
270
|
+
store.mark_batch_failed([notification], nil, '')
|
271
|
+
notification.reload
|
272
|
+
end.to change { notification.failed_at.try(:utc).to_s }.to(time.to_s)
|
273
|
+
end
|
274
|
+
|
275
|
+
it 'sets the error code' do
|
276
|
+
expect do
|
277
|
+
store.mark_batch_failed([notification], 42, '')
|
278
|
+
notification.reload
|
279
|
+
end.to change(notification, :error_code).to(42)
|
280
|
+
end
|
281
|
+
|
282
|
+
it 'sets the error description' do
|
283
|
+
expect do
|
284
|
+
store.mark_batch_failed([notification], 42, 'Weeee')
|
285
|
+
notification.reload
|
286
|
+
end.to change(notification, :error_description).to('Weeee')
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
describe 'create_apns_feedback' do
|
291
|
+
it 'creates the Feedback record' do
|
292
|
+
expect(Rpush::Client::Redis::Apns::Feedback).to receive(:create!).with(
|
293
|
+
failed_at: time, device_token: 'ab' * 32, app_id: app.id)
|
294
|
+
store.create_apns_feedback(time, 'ab' * 32, app)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
describe 'create_gcm_notification' do
|
299
|
+
let(:data) { { data: true } }
|
300
|
+
let(:attributes) { { device_token: 'ab' * 32 } }
|
301
|
+
let(:registration_ids) { %w(123 456) }
|
302
|
+
let(:deliver_after) { time + 10.seconds }
|
303
|
+
let(:args) { [attributes, data, registration_ids, deliver_after, app] }
|
304
|
+
|
305
|
+
it 'sets the given attributes' do
|
306
|
+
new_notification = store.create_gcm_notification(*args)
|
307
|
+
expect(new_notification.device_token).to eq 'ab' * 32
|
308
|
+
end
|
309
|
+
|
310
|
+
it 'sets the given data' do
|
311
|
+
new_notification = store.create_gcm_notification(*args)
|
312
|
+
expect(new_notification.data).to eq(data: true)
|
313
|
+
end
|
314
|
+
|
315
|
+
it 'sets the given registration IDs' do
|
316
|
+
new_notification = store.create_gcm_notification(*args)
|
317
|
+
expect(new_notification.registration_ids).to eq registration_ids
|
318
|
+
end
|
319
|
+
|
320
|
+
it 'sets the deliver_after timestamp' do
|
321
|
+
new_notification = store.create_gcm_notification(*args)
|
322
|
+
expect(new_notification.deliver_after.utc.to_s).to eq deliver_after.to_s
|
323
|
+
end
|
324
|
+
|
325
|
+
it 'saves the new notification' do
|
326
|
+
new_notification = store.create_gcm_notification(*args)
|
327
|
+
expect(new_notification.new_record?).to be_falsey
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
describe 'create_adm_notification' do
|
332
|
+
let(:data) { { data: true } }
|
333
|
+
let(:attributes) { { app_id: app.id, collapse_key: 'ckey', delay_while_idle: true } }
|
334
|
+
let(:registration_ids) { %w(123 456) }
|
335
|
+
let(:deliver_after) { time + 10.seconds }
|
336
|
+
let(:args) { [attributes, data, registration_ids, deliver_after, app] }
|
337
|
+
|
338
|
+
it 'sets the given attributes' do
|
339
|
+
new_notification = store.create_adm_notification(*args)
|
340
|
+
expect(new_notification.app_id).to eq app.id
|
341
|
+
expect(new_notification.collapse_key).to eq 'ckey'
|
342
|
+
expect(new_notification.delay_while_idle).to be_truthy
|
343
|
+
end
|
344
|
+
|
345
|
+
it 'sets the given data' do
|
346
|
+
new_notification = store.create_adm_notification(*args)
|
347
|
+
expect(new_notification.data).to eq(data: true)
|
348
|
+
end
|
349
|
+
|
350
|
+
it 'sets the given registration IDs' do
|
351
|
+
new_notification = store.create_adm_notification(*args)
|
352
|
+
expect(new_notification.registration_ids).to eq registration_ids
|
353
|
+
end
|
354
|
+
|
355
|
+
it 'sets the deliver_after timestamp' do
|
356
|
+
new_notification = store.create_adm_notification(*args)
|
357
|
+
expect(new_notification.deliver_after.utc.to_s).to eq deliver_after.to_s
|
358
|
+
end
|
359
|
+
|
360
|
+
it 'saves the new notification' do
|
361
|
+
new_notification = store.create_adm_notification(*args)
|
362
|
+
expect(new_notification.new_record?).to be_falsey
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end if redis?
|
data/spec/unit/embed_spec.rb
CHANGED
@@ -19,8 +19,10 @@ describe Rpush, 'embed' do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'overrides the default config options with those given as a hash' do
|
22
|
-
Rpush.
|
23
|
-
|
22
|
+
Rpush::Deprecation.muted do
|
23
|
+
Rpush.config.push_poll = 4
|
24
|
+
expect { Rpush.embed(push_poll: 2) }.to change(Rpush.config, :push_poll).to(2)
|
25
|
+
end
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
data/spec/unit/logger_spec.rb
CHANGED
@@ -5,11 +5,11 @@ module Rails
|
|
5
5
|
end
|
6
6
|
|
7
7
|
describe Rpush::Logger do
|
8
|
-
let(:log) { double(:sync= => true) }
|
8
|
+
let(:log) { double(:sync= => true, :level= => nil) }
|
9
9
|
|
10
10
|
before do
|
11
11
|
@logger_class = defined?(ActiveSupport::BufferedLogger) ? ActiveSupport::BufferedLogger : ActiveSupport::Logger
|
12
|
-
@logger = double(@logger_class.name, info: nil, error: nil, level: 0, auto_flushing: true, :auto_flushing= => nil)
|
12
|
+
@logger = double(@logger_class.name, info: nil, error: nil, level: 0, :level= => nil, auto_flushing: true, :auto_flushing= => nil)
|
13
13
|
allow(@logger_class).to receive(:new).and_return(@logger)
|
14
14
|
allow(Rails).to receive_messages(logger: @logger)
|
15
15
|
allow(File).to receive_messages(open: log)
|
@@ -41,7 +41,7 @@ describe Rpush::Logger do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'uses the user-defined logger' do
|
44
|
-
my_logger = double
|
44
|
+
my_logger = double(:level= => nil)
|
45
45
|
Rpush.config.logger = my_logger
|
46
46
|
logger = Rpush::Logger.new
|
47
47
|
expect(my_logger).to receive(:info)
|
@@ -51,7 +51,7 @@ describe Rpush::Logger do
|
|
51
51
|
|
52
52
|
it 'uses ActiveSupport::BufferedLogger if a user-defined logger is not set' do
|
53
53
|
if ActiveSupport.const_defined?('BufferedLogger')
|
54
|
-
expect(ActiveSupport::BufferedLogger).to receive(:new).with(log
|
54
|
+
expect(ActiveSupport::BufferedLogger).to receive(:new).with(log)
|
55
55
|
Rpush::Logger.new
|
56
56
|
end
|
57
57
|
end
|
@@ -59,7 +59,16 @@ describe Rpush::Logger do
|
|
59
59
|
it 'uses ActiveSupport::Logger if BufferedLogger does not exist' do
|
60
60
|
stub_const('ActiveSupport::Logger', double)
|
61
61
|
allow(ActiveSupport).to receive_messages(:const_defined? => false)
|
62
|
-
expect(ActiveSupport::Logger).to receive(:new).with(log
|
62
|
+
expect(ActiveSupport::Logger).to receive(:new).with(log).and_return(log)
|
63
|
+
Rpush::Logger.new
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'sets the log level on the logger' do
|
67
|
+
stub_const('ActiveSupport::Logger', double)
|
68
|
+
allow(ActiveSupport).to receive_messages(:const_defined? => false)
|
69
|
+
expect(ActiveSupport::Logger).to receive(:new).with(log).and_return(log)
|
70
|
+
Rpush.config.log_level = ::Logger::Severity::ERROR
|
71
|
+
expect(log).to receive(:level=).with(::Logger::Severity::ERROR)
|
63
72
|
Rpush::Logger.new
|
64
73
|
end
|
65
74
|
|
@@ -18,7 +18,7 @@ shared_examples_for "an Notification subclass" do
|
|
18
18
|
|
19
19
|
it "raises an ArgumentError if something other than a Hash is assigned" do
|
20
20
|
expect do
|
21
|
-
notification.data =
|
21
|
+
notification.data = []
|
22
22
|
end.to raise_error(ArgumentError, "must be a Hash")
|
23
23
|
end
|
24
24
|
|
data/spec/unit/push_spec.rb
CHANGED
@@ -33,7 +33,9 @@ describe Rpush, 'push' do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'overrides the default config options with those given as a hash' do
|
36
|
-
Rpush.
|
37
|
-
|
36
|
+
Rpush::Deprecation.muted do
|
37
|
+
Rpush.config.batch_size = 20
|
38
|
+
expect { Rpush.push(batch_size: 10) }.to change(Rpush.config, :batch_size).to(10)
|
39
|
+
end
|
38
40
|
end
|
39
41
|
end
|
data/spec/unit_spec_helper.rb
CHANGED
@@ -13,9 +13,9 @@ RSpec.configure do |config|
|
|
13
13
|
config.before(:each) do
|
14
14
|
Modis.with_connection do |redis|
|
15
15
|
redis.keys('rpush:*').each { |key| redis.del(key) }
|
16
|
-
end
|
16
|
+
end if redis?
|
17
17
|
|
18
|
-
if unit_example?(self.class.metadata)
|
18
|
+
if active_record? && unit_example?(self.class.metadata)
|
19
19
|
connection = ActiveRecord::Base.connection
|
20
20
|
|
21
21
|
if rails4?
|
@@ -29,7 +29,7 @@ RSpec.configure do |config|
|
|
29
29
|
end
|
30
30
|
|
31
31
|
config.after(:each) do
|
32
|
-
if unit_example?(self.class.metadata)
|
32
|
+
if active_record? && unit_example?(self.class.metadata)
|
33
33
|
connection = ActiveRecord::Base.connection
|
34
34
|
|
35
35
|
if rails4?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Ian Leitch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- CHANGELOG.md
|
140
140
|
- LICENSE
|
141
141
|
- README.md
|
142
|
+
- bin/rpush
|
142
143
|
- lib/generators/rpush_config_generator.rb
|
143
144
|
- lib/generators/rpush_migration_generator.rb
|
144
145
|
- lib/generators/templates/add_adm.rb
|
@@ -186,6 +187,18 @@ files:
|
|
186
187
|
- lib/rpush/client/active_record/notification.rb
|
187
188
|
- lib/rpush/client/active_record/wpns/app.rb
|
188
189
|
- lib/rpush/client/active_record/wpns/notification.rb
|
190
|
+
- lib/rpush/client/mongoid.rb
|
191
|
+
- lib/rpush/client/mongoid/adm/app.rb
|
192
|
+
- lib/rpush/client/mongoid/adm/notification.rb
|
193
|
+
- lib/rpush/client/mongoid/apns/app.rb
|
194
|
+
- lib/rpush/client/mongoid/apns/feedback.rb
|
195
|
+
- lib/rpush/client/mongoid/apns/notification.rb
|
196
|
+
- lib/rpush/client/mongoid/app.rb
|
197
|
+
- lib/rpush/client/mongoid/gcm/app.rb
|
198
|
+
- lib/rpush/client/mongoid/gcm/notification.rb
|
199
|
+
- lib/rpush/client/mongoid/notification.rb
|
200
|
+
- lib/rpush/client/mongoid/wpns/app.rb
|
201
|
+
- lib/rpush/client/mongoid/wpns/notification.rb
|
189
202
|
- lib/rpush/client/redis.rb
|
190
203
|
- lib/rpush/client/redis/adm/app.rb
|
191
204
|
- lib/rpush/client/redis/adm/notification.rb
|
@@ -230,6 +243,7 @@ files:
|
|
230
243
|
- lib/rpush/daemon/store/active_record.rb
|
231
244
|
- lib/rpush/daemon/store/active_record/reconnectable.rb
|
232
245
|
- lib/rpush/daemon/store/interface.rb
|
246
|
+
- lib/rpush/daemon/store/mongoid.rb
|
233
247
|
- lib/rpush/daemon/store/redis.rb
|
234
248
|
- lib/rpush/daemon/string_helpers.rb
|
235
249
|
- lib/rpush/daemon/synchronizer.rb
|
@@ -264,6 +278,8 @@ files:
|
|
264
278
|
- spec/support/cert_with_password.pem
|
265
279
|
- spec/support/cert_without_password.pem
|
266
280
|
- spec/support/config/database.yml
|
281
|
+
- spec/support/config/mongoid.yml
|
282
|
+
- spec/support/mongoid_setup.rb
|
267
283
|
- spec/support/simplecov_helper.rb
|
268
284
|
- spec/support/simplecov_quality_formatter.rb
|
269
285
|
- spec/tmp/.gitkeep
|
@@ -293,11 +309,14 @@ files:
|
|
293
309
|
- spec/unit/daemon/dispatcher_loop_spec.rb
|
294
310
|
- spec/unit/daemon/feeder_spec.rb
|
295
311
|
- spec/unit/daemon/gcm/delivery_spec.rb
|
312
|
+
- spec/unit/daemon/proc_title_spec.rb
|
296
313
|
- spec/unit/daemon/retryable_error_spec.rb
|
297
314
|
- spec/unit/daemon/service_config_methods_spec.rb
|
298
315
|
- spec/unit/daemon/signal_handler_spec.rb
|
299
316
|
- spec/unit/daemon/store/active_record/reconnectable_spec.rb
|
300
317
|
- spec/unit/daemon/store/active_record_spec.rb
|
318
|
+
- spec/unit/daemon/store/mongoid_spec.rb
|
319
|
+
- spec/unit/daemon/store/redis_spec.rb
|
301
320
|
- spec/unit/daemon/tcp_connection_spec.rb
|
302
321
|
- spec/unit/daemon/wpns/delivery_spec.rb
|
303
322
|
- spec/unit/daemon_spec.rb
|
@@ -312,7 +331,6 @@ files:
|
|
312
331
|
- spec/unit/reflection_collection_spec.rb
|
313
332
|
- spec/unit/rpush_spec.rb
|
314
333
|
- spec/unit_spec_helper.rb
|
315
|
-
- bin/rpush
|
316
334
|
homepage: https://github.com/rpush/rpush
|
317
335
|
licenses:
|
318
336
|
- MIT
|
@@ -333,7 +351,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
333
351
|
version: '0'
|
334
352
|
requirements: []
|
335
353
|
rubyforge_project:
|
336
|
-
rubygems_version: 2.
|
354
|
+
rubygems_version: 2.4.5
|
337
355
|
signing_key:
|
338
356
|
specification_version: 4
|
339
357
|
summary: The push notification service for Ruby.
|
@@ -353,6 +371,8 @@ test_files:
|
|
353
371
|
- spec/support/cert_with_password.pem
|
354
372
|
- spec/support/cert_without_password.pem
|
355
373
|
- spec/support/config/database.yml
|
374
|
+
- spec/support/config/mongoid.yml
|
375
|
+
- spec/support/mongoid_setup.rb
|
356
376
|
- spec/support/simplecov_helper.rb
|
357
377
|
- spec/support/simplecov_quality_formatter.rb
|
358
378
|
- spec/tmp/.gitkeep
|
@@ -382,11 +402,14 @@ test_files:
|
|
382
402
|
- spec/unit/daemon/dispatcher_loop_spec.rb
|
383
403
|
- spec/unit/daemon/feeder_spec.rb
|
384
404
|
- spec/unit/daemon/gcm/delivery_spec.rb
|
405
|
+
- spec/unit/daemon/proc_title_spec.rb
|
385
406
|
- spec/unit/daemon/retryable_error_spec.rb
|
386
407
|
- spec/unit/daemon/service_config_methods_spec.rb
|
387
408
|
- spec/unit/daemon/signal_handler_spec.rb
|
388
409
|
- spec/unit/daemon/store/active_record/reconnectable_spec.rb
|
389
410
|
- spec/unit/daemon/store/active_record_spec.rb
|
411
|
+
- spec/unit/daemon/store/mongoid_spec.rb
|
412
|
+
- spec/unit/daemon/store/redis_spec.rb
|
390
413
|
- spec/unit/daemon/tcp_connection_spec.rb
|
391
414
|
- spec/unit/daemon/wpns/delivery_spec.rb
|
392
415
|
- spec/unit/daemon_spec.rb
|