pushr-apns 1.0.0.pre.3 → 1.0.0.pre.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efc2bbab50485a9c869eedbe32b47a5493780034
4
- data.tar.gz: 5f287d84ca34d2ccaf2c06e234e6955d9d8845d2
3
+ metadata.gz: 003fa0a9aa2c107746eb4affaa5a22ff13c39914
4
+ data.tar.gz: 20aa0e25b3561f31d0fe2fe4bcc0f13b76beaf4e
5
5
  SHA512:
6
- metadata.gz: f2a3c1e7ae567fe58e1d6941ba81f069ac0d56d2f9c41af18266536b478a35b40fc02ad15a77534aef7fea6aad079807ff272c4b6523d1e09c7c7e30648f05a8
7
- data.tar.gz: 71d2da4ef4ce5663649523fd0efe35bf22dff0247beef7e30b4ea4f2d189b8a55d16ef0009f4d572d526d3eaacc8172a629090a7daf60ee82f9520c3458608af
6
+ metadata.gz: 5d6a328bb38292445943e19b7fbd9d8ffa7eec962b16d4534afe26c3b930e2d361ec6dc9a96cdeb2587a094e7442db71245f168460acee8bcf8d607a19868fb0
7
+ data.tar.gz: 0712b0857645b13c3be749bbf0b6f6a89eadcac3c8292efab28512badafe86309027bd72ec3d589b016f8f9ef841008f1afabdee13dd2f71e95474cd0d69de5a
@@ -1,3 +1,3 @@
1
1
  module PushrApns
2
- VERSION = '1.0.0.pre.3'
2
+ VERSION = '1.0.0.pre.4'
3
3
  end
@@ -97,8 +97,6 @@ module Pushr
97
97
  if tuple = read(ERROR_TUPLE_BYTES)
98
98
  _, code, notification_id = tuple.unpack('ccN')
99
99
 
100
- # TODO: if error 8, create feedback object to remove
101
- # Pushr::FeedbackApns.new(app: notification.app, failed_at: Time.now, device: notification.device, follow_up: 'delete').save
102
100
  description = APN_ERRORS[code.to_i] || 'Unknown error. Possible push bug?'
103
101
  error = Pushr::Daemon::DeliveryError.new(code, notification_id, description, 'APNS')
104
102
  else
@@ -10,6 +10,7 @@ module Pushr
10
10
  validates :priority, inclusion: { in: [5, 10] }
11
11
  validates :content_available, inclusion: { in: [1] }, allow_nil: true
12
12
  validate :max_payload_size
13
+ validate :priority_with_content_available
13
14
 
14
15
  def alert=(alert)
15
16
  if alert.is_a?(Hash)
@@ -73,5 +74,11 @@ module Pushr
73
74
  errors.add(:payload, 'APN notification cannot be larger than 256 bytes. Try condensing your alert and device attributes.')
74
75
  end
75
76
  end
77
+
78
+ def priority_with_content_available
79
+ if content_available == 1 && priority != 5 && !(alert || badge || sound)
80
+ errors.add(:priority, 'Priority should be 5 if content_available = 1 and no alert/badge/sound')
81
+ end
82
+ end
76
83
  end
77
84
  end
@@ -17,7 +17,7 @@ describe Pushr::MessageApns do
17
17
 
18
18
  describe 'save' do
19
19
  let(:message) do
20
- hsh = { app: 'app_name', device: 'a' * 64, alert: 'message', badge: 1, sound: '1.aiff',
20
+ hsh = { app: 'app_name', device: 'a' * 64, alert: 'message', badge: 1, sound: '1.aiff',
21
21
  expiry: 24 * 60 * 60, attributes_for_device: { key: 'test' }, priority: 10 }
22
22
  Pushr::MessageApns.new(hsh)
23
23
  end
@@ -32,5 +32,49 @@ describe Pushr::MessageApns do
32
32
  it 'should respond to to_message' do
33
33
  expect(message.to_message).to be_kind_of(String)
34
34
  end
35
+
36
+ context 'content-available: 1' do
37
+ context 'with no alert/badge/sound' do
38
+ let(:message) do
39
+ hsh = { app: 'app_name', device: 'a' * 64, expiry: 24 * 60 * 60, priority: priority, content_available: 1 }
40
+ Pushr::MessageApns.new(hsh)
41
+ end
42
+
43
+ context 'with priority 5' do
44
+ let(:priority) { 5 }
45
+ it 'should have priority 5' do
46
+ expect(message.save).to eql true
47
+ end
48
+ end
49
+
50
+ context 'with priority 10' do
51
+ let(:priority) { 10 }
52
+ it 'should be invalid if priority 10' do
53
+ expect(message.save).to eql false
54
+ end
55
+ end
56
+ end
57
+
58
+ context 'with alert/badge/sound' do
59
+ let(:message) do
60
+ hsh = { app: 'app_name', alert: 'test', device: 'a' * 64, expiry: 24 * 60 * 60, priority: priority, content_available: 1 }
61
+ Pushr::MessageApns.new(hsh)
62
+ end
63
+
64
+ context 'with priority 5' do
65
+ let(:priority) { 5 }
66
+ it 'should have priority 5' do
67
+ expect(message.save).to eql true
68
+ end
69
+ end
70
+
71
+ context 'with priority 10' do
72
+ let(:priority) { 10 }
73
+ it 'should be valid if priority 10' do
74
+ expect(message.save).to eql true
75
+ end
76
+ end
77
+ end
78
+ end
35
79
  end
36
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushr-apns
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.3
4
+ version: 1.0.0.pre.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Pesman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-27 00:00:00.000000000 Z
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json