resque-aps 0.9.11 → 0.9.12

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.9.12 (2010-08-31)
2
+
3
+ * Bug fix
4
+
1
5
  ## 0.9.11 (2010-08-31)
2
6
 
3
7
  * Added version 2 of the push protocol
@@ -79,7 +79,7 @@ module Resque
79
79
  end
80
80
 
81
81
  def enqueue_aps_application(application_name, override = false)
82
- count_apps = aps_applications_queued_count(application_name)
82
+ count_apps = aps_applications_queued_count(application_name).to_i
83
83
  count_not = aps_notification_count_for_application(application_name)
84
84
  if override || count_apps <= 0 || (count_apps < aps_application_job_limit && (count_not > aps_queue_size_upper && count_not % (aps_queue_size_upper / 10) == 0))
85
85
  enqueue(Resque::Plugins::Aps::Application, application_name)
@@ -88,7 +88,7 @@ module Resque
88
88
  end
89
89
 
90
90
  def dequeue_aps_application(application_name)
91
- redis.decr(aps_application_queued_key(application_name)) if aps_applications_queued_count(application_name) > 0
91
+ redis.decr(aps_application_queued_key(application_name)) if aps_applications_queued_count(application_name).to_i > 0
92
92
  end
93
93
 
94
94
  def enqueue_aps(application_name, notification)
@@ -33,18 +33,20 @@ module Resque
33
33
  app.before_aps_write n
34
34
  begin
35
35
  n.batch_id = count + 1
36
- n.expiry = (Time.now.utc + 1.hour).to_i
36
+ n.expiry = Time.now.utc.to_i + 3600
37
37
  socket.write(n.formatted)
38
38
  app.after_aps_write n
39
39
  count += 1
40
- unless (resp = socket.read).blank?
41
- logger.error "Failure response: #{resp.inspect}" if logger
42
- break
43
- end
40
+ # resp = socket.read
41
+ # if resp && resp != ""
42
+ # # logger.error "Failure response: #{resp.inspect}" if logger
43
+ # logger.error "Failure response: #{resp.bytes.to_a.map{|i| i.to_s(16)}.join}" if logger
44
+ # break
45
+ # end
44
46
  rescue
45
47
  logger.error Application.application_exception($!, app_name) if logger
46
48
  app.failed_aps_write n, $!
47
- logger.error "Sent #{count} notifications before failure." if logger
49
+ logger.error "#{$!}: Sent #{count} notifications before failure." if logger
48
50
  Resque.enqueue_aps(app_name, n)
49
51
  break
50
52
  end
@@ -1,7 +1,7 @@
1
1
  module Resque
2
2
  module Plugins
3
3
  module Aps
4
- Version = '0.9.11'
4
+ Version = '0.9.12'
5
5
  end
6
6
  end
7
7
  end
@@ -19,10 +19,11 @@ context "Resque::Plugins::Aps::Application" do
19
19
  end
20
20
 
21
21
  test "can perform" do
22
- n = Resque::Plugins::Aps::Notification.new('application_name' => 'TestApp', 'device_token' => 'aihdf08u2402hbdfquhiwr', 'payload' => '{"aps": { "alert": "hello"}}')
22
+ n = Resque::Plugins::Aps::Notification.new('application_name' => 'TestApp', 'device_token' => '3ECA0F9A3405B980A88A61A1556AF8B7F1DF5F7F109E1476A781E8220C4FE561', 'payload' => '{"aps": { "alert": "hello"}}')
23
23
  assert Resque.enqueue_aps('TestApp', n)
24
24
  Resque.create_aps_application('TestApp', File.dirname(__FILE__) + "/../test-dev.pem", nil)
25
25
  Resque::Plugins::Aps::Application.perform('TestApp')
26
+ assert_equal 0, Resque.aps_notification_count_for_application('TestApp')
26
27
  end
27
28
 
28
29
  context "ApplicationWithHooks" do
@@ -52,10 +53,19 @@ context "Resque::Plugins::Aps::Application" do
52
53
  end
53
54
 
54
55
  test "can perform with logging hooks" do
56
+ n = Resque::Plugins::Aps::Notification.new('application_name' => 'TestApp', 'device_token' => '3ECA0F9A3405B980A88A61A1556AF8B7F1DF5F7F109E1476A781E8220C4FE561', 'payload' => '{"aps": { "alert": "hello"}}')
57
+ assert Resque.enqueue_aps('TestApp', n)
58
+ Resque.create_aps_application('TestApp', File.dirname(__FILE__) + "/../test-dev.pem", nil)
59
+ Resque::Plugins::Aps::Application.perform('TestApp')
60
+ assert_equal 0, Resque.aps_notification_count_for_application('TestApp')
61
+ end
62
+
63
+ test "can perform with failure logging hooks" do
55
64
  n = Resque::Plugins::Aps::Notification.new('application_name' => 'TestApp', 'device_token' => 'aihdf08u2402hbdfquhiwr', 'payload' => '{"aps": { "alert": "hello"}}')
56
65
  assert Resque.enqueue_aps('TestApp', n)
57
66
  Resque.create_aps_application('TestApp', File.dirname(__FILE__) + "/../test-dev.pem", nil)
58
67
  Resque::Plugins::Aps::Application.perform('TestApp')
68
+ assert_equal 0, Resque.aps_notification_count_for_application('TestApp')
59
69
  end
60
70
  end
61
71
  end
@@ -29,7 +29,7 @@ context "on GET to /aps/some_ivar_application" do
29
29
  setup do
30
30
  Resque.redis.flushall
31
31
  Resque.create_aps_application(:some_ivar_application, nil, nil)
32
- n = Resque::Plugins::Aps::Notification.new('application_name' => 'some_ivar_application', 'device_token' => 'aihdf08u2402hbdfquhiwr', 'payload' => '{"aps": { "alert": "hello"}}')
32
+ n = Resque::Plugins::Aps::Notification.new('application_name' => 'some_ivar_application', 'device_token' => '3ECA0F9A3405B980A88A61A1556AF8B7F1DF5F7F109E1476A781E8220C4FE561', 'payload' => '{"aps": { "alert": "hello"}}')
33
33
  assert Resque.enqueue_aps(:some_ivar_application, n)
34
34
  assert Resque.enqueue_aps(:some_ivar_application, n)
35
35
  assert Resque.enqueue_aps(:some_ivar_application, n)
@@ -8,6 +8,7 @@ require 'rubygems'
8
8
  require 'test/unit'
9
9
  require 'mocha'
10
10
  require 'resque'
11
+ require 'ruby-debug'
11
12
  require File.join(dir, '../lib/resque_aps')
12
13
  $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__)) + '/../lib'
13
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-aps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.11
4
+ version: 0.9.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ashley Martens