urbanairship 1.0.3 → 1.1.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.
data/lib/urbanairship.rb CHANGED
@@ -11,7 +11,6 @@ module Urbanairship
11
11
  Timer = Timeout
12
12
  end
13
13
 
14
- VALID_PUSH_PARAMS = %w(device_tokens aliases tags schedule_for exclude_tokens aps)
15
14
  VALID_REGISTER_PARAMS = %w(alias)
16
15
 
17
16
  class << self
@@ -108,7 +107,7 @@ module Urbanairship
108
107
 
109
108
  def parse_push_options(hash = {})
110
109
  hash[:schedule_for] = hash[:schedule_for].map{|elem| process_scheduled_elem(elem)} unless hash[:schedule_for].nil?
111
- hash.delete_if{|key, value| !VALID_PUSH_PARAMS.include?(key.to_s)}
110
+ hash
112
111
  end
113
112
 
114
113
  def log_request_and_response(request, response, time)
@@ -1,5 +1,4 @@
1
1
  describe Urbanairship do
2
-
3
2
  before(:all) do
4
3
  FakeWeb.allow_net_connect = false
5
4
 
@@ -47,7 +46,6 @@ describe Urbanairship do
47
46
  end
48
47
 
49
48
  describe "configuration" do
50
-
51
49
  it "enables you to configure the application key" do
52
50
  Urbanairship.application_key.should be_nil
53
51
  Urbanairship.application_key = "asdf1234"
@@ -65,11 +63,9 @@ describe Urbanairship do
65
63
  Urbanairship.master_secret = "asdf1234"
66
64
  Urbanairship.master_secret.should == "asdf1234"
67
65
  end
68
-
69
66
  end
70
67
 
71
- describe "registering a device" do
72
-
68
+ describe "::register_device" do
73
69
  before(:each) do
74
70
  @valid_params = {:alias => 'one'}
75
71
  Urbanairship.application_key = "my_app_key"
@@ -137,10 +133,9 @@ describe Urbanairship do
137
133
  Urbanairship.register_device("device_token_one", @valid_params)
138
134
  request_json['foo'].should be_nil
139
135
  end
140
-
141
136
  end
142
137
 
143
- describe "unregistering a device" do
138
+ describe "::unregister_device" do
144
139
  before(:each) do
145
140
  Urbanairship.application_key = "my_app_key"
146
141
  Urbanairship.application_secret = "my_app_secret"
@@ -174,10 +169,9 @@ describe Urbanairship do
174
169
  Urbanairship.application_key = "bad_key"
175
170
  Urbanairship.unregister_device("key_to_delete").should == false
176
171
  end
177
-
178
172
  end
179
173
 
180
- describe "deleting a scheduled push notification" do
174
+ describe "::delete_scheduled_push" do
181
175
  before(:each) do
182
176
  Urbanairship.application_key = "my_app_key"
183
177
  Urbanairship.master_secret = "my_master_secret"
@@ -221,11 +215,9 @@ describe Urbanairship do
221
215
  Urbanairship.application_key = "bad_key"
222
216
  Urbanairship.delete_scheduled_push("123456789").should == false
223
217
  end
224
-
225
218
  end
226
219
 
227
- describe "sending multiple push notifications" do
228
-
220
+ describe "::push" do
229
221
  before(:each) do
230
222
  @valid_params = {:device_tokens => ['device_token_one', 'device_token_two'], :aps => {:alert => 'foo'}}
231
223
  Urbanairship.application_key = "my_app_key"
@@ -260,21 +252,6 @@ describe Urbanairship do
260
252
  FakeWeb.last_request['content-type'].should == 'application/json'
261
253
  end
262
254
 
263
- it "adds device_tokens to the JSON payload" do
264
- Urbanairship.push(@valid_params.merge(:device_tokens => ["one", "two"]))
265
- request_json['device_tokens'].should == ["one", "two"]
266
- end
267
-
268
- it "adds aliases to the JSON payload" do
269
- Urbanairship.push(@valid_params.merge(:aliases => ["one", "two"]))
270
- request_json['aliases'].should == ["one", "two"]
271
- end
272
-
273
- it "adds tags to the JSON payload" do
274
- Urbanairship.push(@valid_params.merge(:tags => ["one", "two"]))
275
- request_json['tags'].should == ["one", "two"]
276
- end
277
-
278
255
  it "adds schedule_for to the JSON payload" do
279
256
  time = Time.parse("Oct 17th, 2010, 8:00 PM UTC")
280
257
  Urbanairship.push(@valid_params.merge(:schedule_for => [time]))
@@ -286,38 +263,14 @@ describe Urbanairship do
286
263
  request_json['schedule_for'].should == ['2010-10-10T09:09:09Z']
287
264
  end
288
265
 
289
- it "adds an aliased schedule_for to the JSON payload" do
290
- time = Time.parse("Oct 17th, 2010, 8:00 PM UTC")
291
- alias_str = 'cafebabe'
292
- Urbanairship.push(@valid_params.merge(:schedule_for => [{ :alias => alias_str, :scheduled_time => time }]))
293
- request_json['schedule_for'].should == [{ 'alias' => alias_str, 'scheduled_time' => '2010-10-17T20:00:00Z' }]
294
- end
295
-
296
- it "adds exclude_tokens to the JSON payload" do
297
- Urbanairship.push(@valid_params.merge(:exclude_tokens => ["one", "two"]))
298
- request_json['exclude_tokens'].should == ["one", "two"]
299
- end
300
-
301
- it "adds aps parameters to the JSON payload" do
302
- Urbanairship.push(@valid_params.merge(:aps => {:badge => 10, :alert => "Hi!", :sound => "cat.caf"}))
303
- request_json['aps'].should == {'badge' => 10, 'alert' => 'Hi!', 'sound' => 'cat.caf'}
304
- end
305
-
306
- it "excludes invalid parameters from the JSON payload" do
307
- Urbanairship.push(@valid_params.merge(:foo => 'bar'))
308
- request_json['foo'].should be_nil
309
- end
310
-
311
266
  it "returns false if urbanairship responds with a non-200 response" do
312
267
  Urbanairship.application_key = "my_app_key2"
313
268
  Urbanairship.master_secret = "my_master_secret2"
314
269
  Urbanairship.push.should == false
315
270
  end
316
-
317
271
  end
318
272
 
319
- describe "sending batch push notifications" do
320
-
273
+ describe "::batch_push" do
321
274
  before(:each) do
322
275
  @valid_params = [
323
276
  {:device_tokens => ['device_token_one', 'device_token_two'], :aps => {:alert => 'foo'}},
@@ -355,24 +308,6 @@ describe Urbanairship do
355
308
  FakeWeb.last_request['content-type'].should == 'application/json'
356
309
  end
357
310
 
358
- it "adds device_tokens to the JSON payload" do
359
- @valid_params[0].merge!(:device_tokens => ["one", "two"])
360
- Urbanairship.batch_push(@valid_params)
361
- request_json[0]['device_tokens'].should == ["one", "two"]
362
- end
363
-
364
- it "adds aliases to the JSON payload" do
365
- @valid_params[0].merge!(:aliases => ["one", "two"])
366
- Urbanairship.batch_push(@valid_params)
367
- request_json[0]['aliases'].should == ["one", "two"]
368
- end
369
-
370
- it "adds tags to the JSON payload" do
371
- @valid_params[0].merge!(:tags => ["one", "two"])
372
- Urbanairship.batch_push(@valid_params)
373
- request_json[0]['tags'].should == ["one", "two"]
374
- end
375
-
376
311
  it "adds schedule_for to the JSON payload" do
377
312
  time = Time.parse("Oct 17th, 2010, 8:00 PM UTC")
378
313
  @valid_params[0].merge!(:schedule_for => [time])
@@ -386,34 +321,14 @@ describe Urbanairship do
386
321
  request_json[0]['schedule_for'].should == ['2010-10-10T09:09:09Z']
387
322
  end
388
323
 
389
- it "adds exclude_tokens to the JSON payload" do
390
- @valid_params[0].merge!(:exclude_tokens => ["one", "two"])
391
- Urbanairship.batch_push(@valid_params)
392
- request_json[0]['exclude_tokens'].should == ["one", "two"]
393
- end
394
-
395
- it "adds aps parameters to the JSON payload" do
396
- @valid_params[0].merge!(:aps => {:badge => 10, :alert => "Hi!", :sound => "cat.caf"})
397
- Urbanairship.batch_push(@valid_params)
398
- request_json[0]['aps'].should == {'badge' => 10, 'alert' => 'Hi!', 'sound' => 'cat.caf'}
399
- end
400
-
401
- it "excludes invalid parameters from the JSON payload" do
402
- @valid_params[0].merge!(:foo => 'bar')
403
- Urbanairship.batch_push(@valid_params)
404
- request_json[0]['foo'].should be_nil
405
- end
406
-
407
324
  it "returns false if urbanairship responds with a non-200 response" do
408
325
  Urbanairship.application_key = "my_app_key2"
409
326
  Urbanairship.master_secret = "my_master_secret2"
410
327
  Urbanairship.batch_push.should == false
411
328
  end
412
-
413
329
  end
414
330
 
415
- describe "sending broadcast push notifications" do
416
-
331
+ describe "::broadcast_push" do
417
332
  before(:each) do
418
333
  @valid_params = {:aps => {:alert => 'foo'}}
419
334
  Urbanairship.application_key = "my_app_key"
@@ -448,18 +363,6 @@ describe Urbanairship do
448
363
  FakeWeb.last_request['content-type'].should == 'application/json'
449
364
  end
450
365
 
451
- it "adds aliases to the JSON payload" do
452
- @valid_params[:aliases] = ["one", "two"]
453
- Urbanairship.broadcast_push(@valid_params)
454
- request_json['aliases'].should == ["one", "two"]
455
- end
456
-
457
- it "adds tags to the JSON payload" do
458
- @valid_params[:tags] = ["one", "two"]
459
- Urbanairship.broadcast_push(@valid_params)
460
- request_json['tags'].should == ["one", "two"]
461
- end
462
-
463
366
  it "adds schedule_for to the JSON payload" do
464
367
  time = Time.parse("Oct 17th, 2010, 8:00 PM UTC")
465
368
  @valid_params[:schedule_for] = [time]
@@ -473,34 +376,14 @@ describe Urbanairship do
473
376
  request_json['schedule_for'].should == ['2010-10-10T09:09:09Z']
474
377
  end
475
378
 
476
- it "adds exclude_tokens to the JSON payload" do
477
- @valid_params[:exclude_tokens] = ["one", "two"]
478
- Urbanairship.broadcast_push(@valid_params)
479
- request_json['exclude_tokens'].should == ["one", "two"]
480
- end
481
-
482
- it "adds aps parameters to the JSON payload" do
483
- @valid_params[:aps] = {:badge => 10, :alert => "Hi!", :sound => "cat.caf"}
484
- Urbanairship.broadcast_push(@valid_params)
485
- request_json['aps'].should == {'badge' => 10, 'alert' => 'Hi!', 'sound' => 'cat.caf'}
486
- end
487
-
488
- it "excludes invalid parameters from the JSON payload" do
489
- @valid_params[:foo] = 'bar'
490
- Urbanairship.broadcast_push(@valid_params)
491
- request_json['foo'].should be_nil
492
- end
493
-
494
379
  it "returns false if urbanairship responds with a non-200 response" do
495
380
  Urbanairship.application_key = "my_app_key2"
496
381
  Urbanairship.master_secret = "my_master_secret2"
497
382
  Urbanairship.broadcast_push.should == false
498
383
  end
499
-
500
384
  end
501
385
 
502
- describe "feedback service" do
503
-
386
+ describe "::feedback" do
504
387
  before(:each) do
505
388
  Urbanairship.application_key = "my_app_key"
506
389
  Urbanairship.master_secret = "my_master_secret"
@@ -546,7 +429,6 @@ describe Urbanairship do
546
429
  JSON.should_not_receive(:parse)
547
430
  Urbanairship.feedback(Time.now).should == false
548
431
  end
549
-
550
432
  end
551
433
 
552
434
  describe "logging" do
@@ -584,7 +466,6 @@ describe Urbanairship do
584
466
  @logger.should_receive(:flush)
585
467
  Urbanairship.feedback(Time.now)
586
468
  end
587
-
588
469
  end
589
470
 
590
471
  describe "request timeout" do
@@ -611,7 +492,6 @@ describe Urbanairship do
611
492
  Urbanairship.register_device('new_device_token')
612
493
  end
613
494
  end
614
-
615
495
  end
616
496
 
617
497
  def request_json
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urbanairship
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 3
10
- version: 1.0.3
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Groupon, Inc.