rpush 5.0.0 → 5.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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -2
  3. data/lib/rpush/cli.rb +1 -1
  4. data/lib/rpush/client/active_model.rb +1 -1
  5. data/lib/rpush/client/active_model/apns/notification.rb +9 -1
  6. data/lib/rpush/client/active_model/apns/notification_payload_size_validator.rb +15 -0
  7. data/lib/rpush/client/active_model/apns2/notification.rb +14 -0
  8. data/lib/rpush/client/active_record.rb +1 -0
  9. data/lib/rpush/client/active_record/apns/active_record_serializable_notification.rb +65 -0
  10. data/lib/rpush/client/active_record/apns/notification.rb +1 -57
  11. data/lib/rpush/client/active_record/apns2/notification.rb +4 -1
  12. data/lib/rpush/client/redis/apns2/notification.rb +1 -0
  13. data/lib/rpush/client/redis/pushy/notification.rb +0 -1
  14. data/lib/rpush/daemon/apns2/delivery.rb +6 -1
  15. data/lib/rpush/daemon/apnsp8/delivery.rb +7 -2
  16. data/lib/rpush/daemon/store/active_record/reconnectable.rb +1 -1
  17. data/lib/rpush/version.rb +1 -1
  18. data/spec/functional/apns2_spec.rb +36 -0
  19. data/spec/support/simplecov_helper.rb +1 -1
  20. data/spec/unit/client/active_record/adm/app_spec.rb +2 -54
  21. data/spec/unit/client/active_record/adm/notification_spec.rb +2 -39
  22. data/spec/unit/client/active_record/apns/app_spec.rb +3 -26
  23. data/spec/unit/client/active_record/apns/feedback_spec.rb +1 -5
  24. data/spec/unit/client/active_record/apns/notification_spec.rb +29 -293
  25. data/spec/unit/client/active_record/apns2/app_spec.rb +4 -0
  26. data/spec/unit/client/active_record/apns2/notification_spec.rb +65 -0
  27. data/spec/unit/client/active_record/app_spec.rb +1 -26
  28. data/spec/unit/client/active_record/gcm/app_spec.rb +3 -1
  29. data/spec/unit/client/active_record/gcm/notification_spec.rb +6 -88
  30. data/spec/unit/client/active_record/notification_spec.rb +3 -11
  31. data/spec/unit/client/active_record/pushy/app_spec.rb +2 -13
  32. data/spec/unit/client/active_record/pushy/notification_spec.rb +2 -55
  33. data/spec/unit/client/active_record/shared/app.rb +14 -0
  34. data/spec/unit/{notification_shared.rb → client/active_record/shared/notification.rb} +12 -7
  35. data/spec/unit/client/active_record/wns/badge_notification_spec.rb +1 -11
  36. data/spec/unit/client/active_record/wns/raw_notification_spec.rb +3 -12
  37. data/spec/unit/client/active_record/wpns/app_spec.rb +3 -1
  38. data/spec/unit/client/active_record/wpns/notification_spec.rb +2 -17
  39. data/spec/unit/client/redis/adm/app_spec.rb +5 -0
  40. data/spec/unit/client/redis/adm/notification_spec.rb +5 -0
  41. data/spec/unit/client/redis/apns/app_spec.rb +5 -0
  42. data/spec/unit/client/redis/apns/feedback_spec.rb +5 -0
  43. data/spec/unit/client/redis/apns/notification_spec.rb +50 -0
  44. data/spec/unit/client/redis/apns2/app_spec.rb +4 -0
  45. data/spec/unit/client/redis/apns2/notification_spec.rb +50 -0
  46. data/spec/unit/client/redis/app_spec.rb +5 -0
  47. data/spec/unit/client/redis/gcm/app_spec.rb +5 -0
  48. data/spec/unit/client/redis/gcm/notification_spec.rb +5 -0
  49. data/spec/unit/client/redis/notification_spec.rb +5 -0
  50. data/spec/unit/client/redis/pushy/app_spec.rb +5 -0
  51. data/spec/unit/client/redis/pushy/notification_spec.rb +5 -0
  52. data/spec/unit/client/redis/wns/badge_notification_spec.rb +5 -0
  53. data/spec/unit/client/redis/wns/raw_notification_spec.rb +22 -0
  54. data/spec/unit/client/redis/wpns/app_spec.rb +5 -0
  55. data/spec/unit/client/redis/wpns/notification_spec.rb +5 -0
  56. data/spec/unit/client/shared/adm/app.rb +51 -0
  57. data/spec/unit/client/shared/adm/notification.rb +39 -0
  58. data/spec/unit/client/shared/apns/app.rb +29 -0
  59. data/spec/unit/client/shared/apns/feedback.rb +9 -0
  60. data/spec/unit/client/shared/apns/notification.rb +262 -0
  61. data/spec/unit/client/shared/app.rb +17 -0
  62. data/spec/unit/client/shared/gcm/app.rb +4 -0
  63. data/spec/unit/client/shared/gcm/notification.rb +77 -0
  64. data/spec/unit/client/shared/notification.rb +10 -0
  65. data/spec/unit/client/shared/pushy/app.rb +17 -0
  66. data/spec/unit/client/shared/pushy/notification.rb +55 -0
  67. data/spec/unit/client/shared/wns/badge_notification.rb +15 -0
  68. data/spec/unit/client/shared/wns/raw_notification.rb +21 -0
  69. data/spec/unit/client/shared/wpns/app.rb +4 -0
  70. data/spec/unit/client/shared/wpns/notification.rb +18 -0
  71. data/spec/unit/daemon/shared/store.rb +312 -0
  72. data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +7 -7
  73. data/spec/unit/daemon/store/active_record_spec.rb +2 -290
  74. data/spec/unit/daemon/store/redis_spec.rb +2 -291
  75. data/spec/unit_spec_helper.rb +3 -0
  76. metadata +89 -10
  77. data/lib/rpush/client/active_model/apns/binary_notification_validator.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: daf8831c7c441107a793e39486aeb6012a321ba26804a64ebd19f48de9043ec8
4
- data.tar.gz: 243005ebaf4ccc03e0b7b6a3ca74e7d20dfb703fbe51255c828ce8f780aca18c
3
+ metadata.gz: 1bd7e063c214b8ab031ca63892ec39f425813c6a1dd9f54f09cfdc5b0e6291b7
4
+ data.tar.gz: '080a33b636882719f1bf2284035a5fe9d22d8073123808a9d1e3acee84622588'
5
5
  SHA512:
6
- metadata.gz: 864f79ac67d9907c87fe9a1d9fa5f34fe7f99c9e1df8b03452791f7ee054d3eba7386f65824780b6c7e7985ae704d74778bb1c18c8bd026bb2edd01875fb327b
7
- data.tar.gz: 2abbf6ed3e8dbe81537dd2107ff77c60d89c3f84879ee391a7eae887b70c1687d58f4ceb0494a2fde5ccf57cde491516de34be553fac0f53c88da49396d7a273
6
+ metadata.gz: e68cf92207ac195e120063301ae6ec23217fbaf31ea46757a9a28163dcc584763e08f26e4e1cf11978bf10a232b9eabd71ef205c4817543d8065e32fc3bf0418
7
+ data.tar.gz: 5bdb35aa1a78ff6f6590072581deb06e29ad51c2255b603c2ed35c985e65fdbb8b524fca80a011d0acae8038dc67579e7cb7d822f24d41ce36da81fb615b3f24
@@ -1,8 +1,20 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased](https://github.com/rpush/rpush/tree/HEAD)
3
+ ## [v5.1.0](https://github.com/rpush/rpush/tree/v5.1.0) (2020-09-25)
4
4
 
5
- [Full Changelog](https://github.com/rpush/rpush/compare/v4.2.0...HEAD)
5
+ [Full Changelog](https://github.com/rpush/rpush/compare/v5.0.0...v5.1.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Resume APNS2 delivery when async requests timeout [\#564](https://github.com/rpush/rpush/pull/564) ([benlangfeld](https://github.com/benlangfeld))
10
+ - Improve DB reconnection for big tables [\#563](https://github.com/rpush/rpush/pull/563) ([AlexTatarnikov](https://github.com/AlexTatarnikov))
11
+ - Default the Rails environment to RAILS_ENV if set [\#562](https://github.com/rpush/rpush/pull/562) ([benlangfeld](https://github.com/benlangfeld))
12
+ - Allow Apns2 payloads to be up to 4096 bytes [\#561](https://github.com/rpush/rpush/pull/561) ([benlangfeld](https://github.com/benlangfeld))
13
+ - Improve test coverage [\#528](https://github.com/rpush/rpush/pull/528) ([jhottenstein](https://github.com/jhottenstein))
14
+
15
+ ## [v5.0.0](https://github.com/rpush/rpush/tree/v5.0.0) (2020-02-21)
16
+
17
+ [Full Changelog](https://github.com/rpush/rpush/compare/v4.2.0...v5.0.0)
6
18
 
7
19
  **Merged pull requests:**
8
20
 
@@ -470,3 +482,5 @@ Bug fixes:
470
482
  - Started the changelog!
471
483
 
472
484
  \* _This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)_
485
+
486
+ \* _This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)_
@@ -14,7 +14,7 @@ module Rpush
14
14
  end
15
15
 
16
16
  class_option :config, type: :string, aliases: '-c', default: default_config_path
17
- class_option 'rails-env', type: :string, aliases: '-e', default: 'development'
17
+ class_option 'rails-env', type: :string, aliases: '-e', default: ENV.fetch('RAILS_ENV', 'development')
18
18
 
19
19
  option :foreground, type: :boolean, aliases: '-f', default: false
20
20
  option 'pid-file', type: :string, aliases: '-p'
@@ -4,10 +4,10 @@ require 'rpush/client/active_model/notification'
4
4
  require 'rpush/client/active_model/payload_data_size_validator'
5
5
  require 'rpush/client/active_model/registration_ids_count_validator'
6
6
 
7
- require 'rpush/client/active_model/apns/binary_notification_validator'
8
7
  require 'rpush/client/active_model/apns/device_token_format_validator'
9
8
  require 'rpush/client/active_model/apns/app'
10
9
  require 'rpush/client/active_model/apns/notification'
10
+ require 'rpush/client/active_model/apns/notification_payload_size_validator'
11
11
 
12
12
  require 'rpush/client/active_model/apns2/app'
13
13
  require 'rpush/client/active_model/apns2/notification'
@@ -7,15 +7,23 @@ module Rpush
7
7
  APNS_PRIORITY_IMMEDIATE = 10
8
8
  APNS_PRIORITY_CONSERVE_POWER = 5
9
9
  APNS_PRIORITIES = [APNS_PRIORITY_IMMEDIATE, APNS_PRIORITY_CONSERVE_POWER]
10
+ MAX_PAYLOAD_BYTESIZE = 2048
11
+
12
+ module ClassMethods
13
+ def max_payload_bytesize
14
+ MAX_PAYLOAD_BYTESIZE
15
+ end
16
+ end
10
17
 
11
18
  def self.included(base)
19
+ base.extend ClassMethods
12
20
  base.instance_eval do
13
21
  validates :device_token, presence: true
14
22
  validates :badge, numericality: true, allow_nil: true
15
23
  validates :priority, inclusion: { in: APNS_PRIORITIES }, allow_nil: true
16
24
 
17
25
  validates_with Rpush::Client::ActiveModel::Apns::DeviceTokenFormatValidator
18
- validates_with Rpush::Client::ActiveModel::Apns::BinaryNotificationValidator
26
+ validates_with Rpush::Client::ActiveModel::Apns::NotificationPayloadSizeValidator
19
27
 
20
28
  base.const_set('APNS_DEFAULT_EXPIRY', APNS_DEFAULT_EXPIRY) unless base.const_defined?('APNS_DEFAULT_EXPIRY')
21
29
  base.const_set('APNS_PRIORITY_IMMEDIATE', APNS_PRIORITY_IMMEDIATE) unless base.const_defined?('APNS_PRIORITY_IMMEDIATE')
@@ -0,0 +1,15 @@
1
+ module Rpush
2
+ module Client
3
+ module ActiveModel
4
+ module Apns
5
+ class NotificationPayloadSizeValidator < ::ActiveModel::Validator
6
+ def validate(record)
7
+ limit = record.class.max_payload_bytesize
8
+ return unless record.payload.bytesize > limit
9
+ record.errors[:base] << "APN notification cannot be larger than #{limit} bytes. Try condensing your alert and device attributes."
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -3,6 +3,20 @@ module Rpush
3
3
  module ActiveModel
4
4
  module Apns2
5
5
  include Rpush::Client::ActiveModel::Apns
6
+
7
+ module Notification
8
+ MAX_PAYLOAD_BYTESIZE = 4096
9
+
10
+ module ClassMethods
11
+ def max_payload_bytesize
12
+ MAX_PAYLOAD_BYTESIZE
13
+ end
14
+ end
15
+
16
+ def self.included(base)
17
+ base.extend ClassMethods
18
+ end
19
+ end
6
20
  end
7
21
  end
8
22
  end
@@ -5,6 +5,7 @@ require 'rpush/client/active_model'
5
5
  require 'rpush/client/active_record/notification'
6
6
  require 'rpush/client/active_record/app'
7
7
 
8
+ require 'rpush/client/active_record/apns/active_record_serializable_notification'
8
9
  require 'rpush/client/active_record/apns/notification'
9
10
  require 'rpush/client/active_record/apns/feedback'
10
11
  require 'rpush/client/active_record/apns/app'
@@ -0,0 +1,65 @@
1
+ module Rpush
2
+ module Client
3
+ module ActiveRecord
4
+ module Apns
5
+ module ActiveRecordSerializableNotification
6
+ def alert=(alert)
7
+ if alert.is_a?(Hash)
8
+ write_attribute(:alert, multi_json_dump(alert))
9
+ self.alert_is_json = true if has_attribute?(:alert_is_json)
10
+ else
11
+ write_attribute(:alert, alert)
12
+ self.alert_is_json = false if has_attribute?(:alert_is_json)
13
+ end
14
+ end
15
+
16
+ def alert
17
+ string_or_json = read_attribute(:alert)
18
+
19
+ if has_attribute?(:alert_is_json)
20
+ if alert_is_json?
21
+ multi_json_load(string_or_json)
22
+ else
23
+ string_or_json
24
+ end
25
+ else
26
+ begin
27
+ multi_json_load(string_or_json)
28
+ rescue StandardError
29
+ string_or_json
30
+ end
31
+ end
32
+ end
33
+
34
+ def sound=(sound)
35
+ if sound.is_a?(Hash)
36
+ write_attribute(:sound, multi_json_dump(sound))
37
+ self.sound_is_json = true if has_attribute?(:sound_is_json)
38
+ else
39
+ write_attribute(:sound, sound)
40
+ self.sound_is_json = false if has_attribute?(:sound_is_json)
41
+ end
42
+ end
43
+
44
+ def sound
45
+ string_or_json = read_attribute(:sound)
46
+
47
+ if has_attribute?(:sound_is_json)
48
+ if sound_is_json?
49
+ multi_json_load(string_or_json)
50
+ else
51
+ string_or_json
52
+ end
53
+ else
54
+ begin
55
+ multi_json_load(string_or_json)
56
+ rescue StandardError
57
+ string_or_json
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -3,64 +3,8 @@ module Rpush
3
3
  module ActiveRecord
4
4
  module Apns
5
5
  class Notification < Rpush::Client::ActiveRecord::Notification
6
- include Deprecatable
7
6
  include Rpush::Client::ActiveModel::Apns::Notification
8
-
9
- def alert=(alert)
10
- if alert.is_a?(Hash)
11
- write_attribute(:alert, multi_json_dump(alert))
12
- self.alert_is_json = true if has_attribute?(:alert_is_json)
13
- else
14
- write_attribute(:alert, alert)
15
- self.alert_is_json = false if has_attribute?(:alert_is_json)
16
- end
17
- end
18
-
19
- def alert
20
- string_or_json = read_attribute(:alert)
21
-
22
- if has_attribute?(:alert_is_json)
23
- if alert_is_json?
24
- multi_json_load(string_or_json)
25
- else
26
- string_or_json
27
- end
28
- else
29
- begin
30
- multi_json_load(string_or_json)
31
- rescue StandardError
32
- string_or_json
33
- end
34
- end
35
- end
36
-
37
- def sound=(sound)
38
- if sound.is_a?(Hash)
39
- write_attribute(:sound, multi_json_dump(sound))
40
- self.sound_is_json = true if has_attribute?(:sound_is_json)
41
- else
42
- write_attribute(:sound, sound)
43
- self.sound_is_json = false if has_attribute?(:sound_is_json)
44
- end
45
- end
46
-
47
- def sound
48
- string_or_json = read_attribute(:sound)
49
-
50
- if has_attribute?(:sound_is_json)
51
- if sound_is_json?
52
- multi_json_load(string_or_json)
53
- else
54
- string_or_json
55
- end
56
- else
57
- begin
58
- multi_json_load(string_or_json)
59
- rescue StandardError
60
- string_or_json
61
- end
62
- end
63
- end
7
+ include ActiveRecordSerializableNotification
64
8
  end
65
9
  end
66
10
  end
@@ -2,7 +2,10 @@ module Rpush
2
2
  module Client
3
3
  module ActiveRecord
4
4
  module Apns2
5
- class Notification < Rpush::Client::ActiveRecord::Apns::Notification
5
+ class Notification < Rpush::Client::ActiveRecord::Notification
6
+ include Rpush::Client::ActiveModel::Apns::Notification
7
+ include Rpush::Client::ActiveModel::Apns2::Notification
8
+ include Rpush::Client::ActiveRecord::Apns::ActiveRecordSerializableNotification
6
9
  end
7
10
  end
8
11
  end
@@ -3,6 +3,7 @@ module Rpush
3
3
  module Redis
4
4
  module Apns2
5
5
  class Notification < Rpush::Client::Redis::Notification
6
+ include Rpush::Client::ActiveModel::Apns::Notification
6
7
  include Rpush::Client::ActiveModel::Apns2::Notification
7
8
  end
8
9
  end
@@ -9,7 +9,6 @@ module Rpush
9
9
 
10
10
  def time_to_live=(value)
11
11
  self.expiry = value
12
- super
13
12
  end
14
13
  end
15
14
  end
@@ -7,6 +7,7 @@ module Rpush
7
7
 
8
8
  class Delivery < Rpush::Daemon::Delivery
9
9
  RETRYABLE_CODES = [ 429, 500, 503 ]
10
+ CLIENT_JOIN_TIMEOUT = 60
10
11
 
11
12
  def initialize(app, http2_client, batch)
12
13
  @app = app
@@ -20,7 +21,11 @@ module Rpush
20
21
  end
21
22
 
22
23
  # Send all preprocessed requests at once
23
- @client.join
24
+ @client.join(timeout: CLIENT_JOIN_TIMEOUT)
25
+ rescue NetHttp2::AsyncRequestTimeout => error
26
+ mark_batch_retryable(Time.now + 10.seconds, error)
27
+ @client.close
28
+ raise
24
29
  rescue Errno::ECONNREFUSED, SocketError => error
25
30
  mark_batch_retryable(Time.now + 10.seconds, error)
26
31
  raise
@@ -7,6 +7,7 @@ module Rpush
7
7
 
8
8
  class Delivery < Rpush::Daemon::Delivery
9
9
  RETRYABLE_CODES = [ 429, 500, 503 ]
10
+ CLIENT_JOIN_TIMEOUT = 60
10
11
 
11
12
  def initialize(app, http2_client, token_provider, batch)
12
13
  @app = app
@@ -22,7 +23,11 @@ module Rpush
22
23
  end
23
24
 
24
25
  # Send all preprocessed requests at once
25
- @client.join
26
+ @client.join(timeout: CLIENT_JOIN_TIMEOUT)
27
+ rescue NetHttp2::AsyncRequestTimeout => error
28
+ mark_batch_retryable(Time.now + 10.seconds, error)
29
+ @client.close
30
+ raise
26
31
  rescue Errno::ECONNREFUSED, SocketError, HTTP2::Error::StreamLimitExceeded => error
27
32
  # TODO restart connection when StreamLimitExceeded
28
33
  mark_batch_retryable(Time.now + 10.seconds, error)
@@ -133,7 +138,7 @@ module Rpush
133
138
  jwt_token = @token_provider.token
134
139
 
135
140
  headers = {}
136
-
141
+
137
142
  headers['content-type'] = 'application/json'
138
143
  headers['apns-expiration'] = '0'
139
144
  headers['apns-priority'] = '10'
@@ -67,7 +67,7 @@ module Rpush
67
67
 
68
68
  def check_database_is_connected
69
69
  # Simply asking the adapter for the connection state is not sufficient.
70
- Rpush::Client::ActiveRecord::Notification.count
70
+ Rpush::Client::ActiveRecord::Notification.exists?
71
71
  end
72
72
 
73
73
  def sleep_to_avoid_thrashing
@@ -1,7 +1,7 @@
1
1
  module Rpush
2
2
  module VERSION
3
3
  MAJOR = 5
4
- MINOR = 0
4
+ MINOR = 1
5
5
  TINY = 0
6
6
  PRE = nil
7
7
 
@@ -228,5 +228,41 @@ describe 'APNs http2 adapter' do
228
228
  Rpush.push
229
229
  end
230
230
  end
231
+
232
+ context 'when waiting for requests to complete times out' do
233
+ before(:each) do
234
+ expect(fake_client).to receive(:join) { raise(NetHttp2::AsyncRequestTimeout) }
235
+ end
236
+
237
+ it 'closes the client' do
238
+ create_notification
239
+ expect(fake_client).to receive(:close)
240
+ Rpush.push
241
+ end
242
+
243
+ it 'reflects :error' do
244
+ reflected_error = false
245
+ Rpush.reflect do |on|
246
+ on.error do |error|
247
+ reflected_error = true
248
+ expect(error).to be_kind_of(StandardError)
249
+ reflector.accept
250
+ end
251
+ end
252
+
253
+ notification = create_notification
254
+ Rpush.push
255
+
256
+ expect(reflected_error).to be true
257
+ end
258
+
259
+ it 'fails but retries delivery several times' do
260
+ notification = create_notification
261
+ expect do
262
+ Rpush.push
263
+ notification.reload
264
+ end.to change(notification, :retries)
265
+ end
266
+ end
231
267
  end
232
268
  end
@@ -18,7 +18,7 @@ module SimpleCovHelper
18
18
  end
19
19
  end
20
20
 
21
- formatter SimpleCov::Formatter::MultiFormatter[*formatters]
21
+ formatter SimpleCov::Formatter::MultiFormatter.new(formatters)
22
22
  end
23
23
  end
24
24
  end
@@ -1,58 +1,6 @@
1
1
  require 'unit_spec_helper'
2
2
 
3
3
  describe Rpush::Client::ActiveRecord::Adm::App do
4
- subject { Rpush::Client::ActiveRecord::Adm::App.new(name: 'test', environment: 'development', client_id: 'CLIENT_ID', client_secret: 'CLIENT_SECRET') }
5
- let(:existing_app) { Rpush::Client::ActiveRecord::Adm::App.create!(name: 'existing', environment: 'development', client_id: 'CLIENT_ID', client_secret: 'CLIENT_SECRET') }
6
-
7
- it 'should be valid if properly instantiated' do
8
- expect(subject).to be_valid
9
- end
10
-
11
- it 'should be invalid if name' do
12
- subject.name = nil
13
- expect(subject).not_to be_valid
14
- expect(subject.errors[:name]).to eq ["can't be blank"]
15
- end
16
-
17
- it 'should be invalid if name is not unique within scope' do
18
- subject.name = existing_app.name
19
- expect(subject).not_to be_valid
20
- expect(subject.errors[:name]).to eq ["has already been taken"]
21
- end
22
-
23
- it 'should be invalid if missing client_id' do
24
- subject.client_id = nil
25
- expect(subject).not_to be_valid
26
- expect(subject.errors[:client_id]).to eq ["can't be blank"]
27
- end
28
-
29
- it 'should be invalid if missing client_secret' do
30
- subject.client_secret = nil
31
- expect(subject).not_to be_valid
32
- expect(subject.errors[:client_secret]).to eq ["can't be blank"]
33
- end
34
-
35
- describe '#access_token_expired?' do
36
- before(:each) do
37
- Timecop.freeze(Time.now)
38
- end
39
-
40
- after do
41
- Timecop.return
42
- end
43
-
44
- it 'should return true if access_token_expiration is nil' do
45
- expect(subject.access_token_expired?).to eq(true)
46
- end
47
-
48
- it 'should return true if expired' do
49
- subject.access_token_expiration = Time.now - 5.minutes
50
- expect(subject.access_token_expired?).to eq(true)
51
- end
52
-
53
- it 'should return false if not expired' do
54
- subject.access_token_expiration = Time.now + 5.minutes
55
- expect(subject.access_token_expired?).to eq(false)
56
- end
57
- end
4
+ it_behaves_like 'Rpush::Client::Adm::App'
5
+ it_behaves_like 'Rpush::Client::ActiveRecord::App'
58
6
  end if active_record?