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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +1 -1
  4. data/lib/generators/rpush_migration_generator.rb +21 -6
  5. data/lib/generators/templates/rpush.rb +5 -5
  6. data/lib/generators/templates/rpush_2_0_0_updates.rb +24 -0
  7. data/lib/rpush/client/active_model/apns/notification.rb +1 -1
  8. data/lib/rpush/client/mongoid/adm/app.rb +14 -0
  9. data/lib/rpush/client/mongoid/adm/notification.rb +11 -0
  10. data/lib/rpush/client/mongoid/apns/app.rb +11 -0
  11. data/lib/rpush/client/mongoid/apns/feedback.rb +21 -0
  12. data/lib/rpush/client/mongoid/apns/notification.rb +15 -0
  13. data/lib/rpush/client/mongoid/app.rb +23 -0
  14. data/lib/rpush/client/mongoid/gcm/app.rb +11 -0
  15. data/lib/rpush/client/mongoid/gcm/notification.rb +11 -0
  16. data/lib/rpush/client/mongoid/notification.rb +43 -0
  17. data/lib/rpush/client/mongoid/wpns/app.rb +11 -0
  18. data/lib/rpush/client/mongoid/wpns/notification.rb +11 -0
  19. data/lib/rpush/client/mongoid.rb +31 -0
  20. data/lib/rpush/client/redis.rb +2 -2
  21. data/lib/rpush/configuration.rb +48 -29
  22. data/lib/rpush/daemon/adm/delivery.rb +1 -1
  23. data/lib/rpush/daemon/apns/feedback_receiver.rb +2 -3
  24. data/lib/rpush/daemon/apns.rb +1 -1
  25. data/lib/rpush/daemon/dispatcher/apns_tcp.rb +2 -1
  26. data/lib/rpush/daemon/feeder.rb +4 -7
  27. data/lib/rpush/daemon/gcm/delivery.rb +1 -1
  28. data/lib/rpush/daemon/interruptible_sleep.rb +5 -50
  29. data/lib/rpush/daemon/proc_title.rb +2 -1
  30. data/lib/rpush/daemon/store/active_record.rb +4 -0
  31. data/lib/rpush/daemon/store/interface.rb +1 -1
  32. data/lib/rpush/daemon/store/mongoid.rb +157 -0
  33. data/lib/rpush/daemon/store/redis.rb +6 -2
  34. data/lib/rpush/deprecatable.rb +1 -2
  35. data/lib/rpush/deprecation.rb +6 -0
  36. data/lib/rpush/embed.rb +5 -0
  37. data/lib/rpush/logger.rb +5 -8
  38. data/lib/rpush/push.rb +5 -0
  39. data/lib/rpush/version.rb +1 -1
  40. data/lib/tasks/quality.rake +1 -1
  41. data/lib/tasks/test.rake +9 -4
  42. data/spec/functional/apns_spec.rb +2 -1
  43. data/spec/functional_spec_helper.rb +2 -2
  44. data/spec/spec_helper.rb +18 -7
  45. data/spec/support/config/mongoid.yml +69 -0
  46. data/spec/support/mongoid_setup.rb +10 -0
  47. data/spec/unit/client/active_record/adm/app_spec.rb +1 -1
  48. data/spec/unit/client/active_record/adm/notification_spec.rb +1 -1
  49. data/spec/unit/client/active_record/apns/app_spec.rb +1 -1
  50. data/spec/unit/client/active_record/apns/feedback_spec.rb +1 -1
  51. data/spec/unit/client/active_record/apns/notification_spec.rb +11 -11
  52. data/spec/unit/client/active_record/app_spec.rb +1 -1
  53. data/spec/unit/client/active_record/gcm/notification_spec.rb +1 -1
  54. data/spec/unit/client/active_record/notification_spec.rb +1 -1
  55. data/spec/unit/client/active_record/wpns/notification_spec.rb +1 -1
  56. data/spec/unit/configuration_spec.rb +7 -0
  57. data/spec/unit/daemon/apns/feedback_receiver_spec.rb +5 -5
  58. data/spec/unit/daemon/feeder_spec.rb +2 -2
  59. data/spec/unit/daemon/proc_title_spec.rb +11 -0
  60. data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +1 -1
  61. data/spec/unit/daemon/store/active_record_spec.rb +21 -12
  62. data/spec/unit/daemon/store/mongoid_spec.rb +339 -0
  63. data/spec/unit/daemon/store/redis_spec.rb +365 -0
  64. data/spec/unit/embed_spec.rb +4 -2
  65. data/spec/unit/logger_spec.rb +14 -5
  66. data/spec/unit/notification_shared.rb +1 -1
  67. data/spec/unit/push_spec.rb +4 -2
  68. data/spec/unit_spec_helper.rb +3 -3
  69. metadata +27 -4
@@ -3,60 +3,15 @@ require 'monitor'
3
3
  module Rpush
4
4
  module Daemon
5
5
  class InterruptibleSleep
6
- def initialize(duration)
7
- @duration = duration
8
- @stop = false
9
-
10
- @wakeup_obj = Object.new
11
- @wakeup_obj.extend(MonitorMixin)
12
- @wakeup_condition = @wakeup_obj.new_cond
13
-
14
- @sleep_obj = Object.new
15
- @sleep_obj.extend(MonitorMixin)
16
- @sleep_condition = @sleep_obj.new_cond
17
- end
18
-
19
- def sleep
20
- return if @stop
21
- goto_sleep
22
- wait_for_wakeup
23
- end
24
-
25
- def start
26
- @stop = false
27
-
28
- @thread = Thread.new do
29
- loop do
30
- wait_for_sleeper
31
- break if @stop
32
- Kernel.sleep(@duration)
33
- wakeup
34
- end
35
- end
6
+ def sleep(duration)
7
+ @thread = Thread.new { Kernel.sleep duration }
8
+ Thread.pass
9
+ @thread.join
36
10
  end
37
11
 
38
12
  def stop
39
- @stop = true
40
- wakeup
41
13
  @thread.kill if @thread
42
- end
43
-
44
- def wakeup
45
- @wakeup_obj.synchronize { @wakeup_condition.signal }
46
- end
47
-
48
- private
49
-
50
- def goto_sleep
51
- @sleep_obj.synchronize { @sleep_condition.signal }
52
- end
53
-
54
- def wait_for_wakeup
55
- @wakeup_obj.synchronize { @wakeup_condition.wait(@duration * 2) }
56
- end
57
-
58
- def wait_for_sleeper
59
- @sleep_obj.synchronize { @sleep_condition.wait }
14
+ rescue StandardError # rubocop:disable Lint/HandleExceptions
60
15
  end
61
16
  end
62
17
  end
@@ -2,7 +2,8 @@ module Rpush
2
2
  module Daemon
3
3
  class ProcTitle
4
4
  def self.update
5
- $0 = proc_title
5
+ return if Rpush.config.embedded || Rpush.config.push
6
+ Process.respond_to?(:setproctitle) ? Process.setproctitle(proc_title) : $0 = proc_title
6
7
  end
7
8
 
8
9
  def self.proc_title
@@ -169,6 +169,10 @@ module Rpush
169
169
  ready_for_delivery.count
170
170
  end
171
171
 
172
+ def translate_integer_notification_id(id)
173
+ id
174
+ end
175
+
172
176
  private
173
177
 
174
178
  def create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app) # rubocop:disable ParameterLists
@@ -8,7 +8,7 @@ module Rpush
8
8
  :create_gcm_notification, :create_adm_notification, :update_app,
9
9
  :update_notification, :release_connection,
10
10
  :all_apps, :app, :mark_ids_failed, :mark_ids_retryable,
11
- :reopen_log, :pending_delivery_count]
11
+ :reopen_log, :pending_delivery_count, :translate_integer_notification_id]
12
12
 
13
13
  def self.check(klass)
14
14
  missing = PUBLIC_METHODS - klass.instance_methods.map(&:to_sym)
@@ -0,0 +1,157 @@
1
+ module Rpush
2
+ module Daemon
3
+ module Store
4
+ class Mongoid
5
+ DEFAULT_MARK_OPTIONS = { persist: true }
6
+
7
+ def app(app_id)
8
+ Rpush::Client::Mongoid::App.find(app_id)
9
+ end
10
+
11
+ def all_apps
12
+ Rpush::Client::Mongoid::App.all
13
+ end
14
+
15
+ def deliverable_notifications(limit)
16
+ relation = ready_for_delivery.limit(limit)
17
+ claim_notifications(relation)
18
+ end
19
+
20
+ def mark_delivered(notification, time, opts = {})
21
+ opts = DEFAULT_MARK_OPTIONS.dup.merge(opts)
22
+ notification.delivered = true
23
+ notification.delivered_at = time
24
+ notification.save!(validate: false) if opts[:persist]
25
+ end
26
+
27
+ def mark_batch_delivered(notifications)
28
+ return if notifications.empty?
29
+
30
+ now = Time.now
31
+ ids = []
32
+ notifications.each do |n|
33
+ mark_delivered(n, now, persist: false)
34
+ ids << n.id
35
+ end
36
+ Rpush::Client::Mongoid::Notification.in(id: ids).update_all(processing: false, delivered: true, delivered_at: now)
37
+ end
38
+
39
+ def mark_failed(notification, code, description, time, opts = {})
40
+ opts = DEFAULT_MARK_OPTIONS.dup.merge(opts)
41
+ notification.delivered = false
42
+ notification.delivered_at = nil
43
+ notification.failed = true
44
+ notification.failed_at = time
45
+ notification.error_code = code
46
+ notification.error_description = description
47
+ notification.save!(validate: false) if opts[:persist]
48
+ end
49
+
50
+ def mark_batch_failed(notifications, code, description)
51
+ now = Time.now
52
+ ids = []
53
+ notifications.each do |n|
54
+ mark_failed(n, code, description, now, persist: false)
55
+ ids << n.id
56
+ end
57
+ mark_ids_failed(ids, code, description, now)
58
+ end
59
+
60
+ def mark_ids_failed(ids, code, description, time)
61
+ return if ids.empty?
62
+
63
+ Rpush::Client::Mongoid::Notification.in(id: ids).update_all(processing: false, delivered: false, delivered_at: nil, failed: true, failed_at: time, error_code: code, error_description: description)
64
+ end
65
+
66
+ def mark_retryable(notification, deliver_after, opts = {})
67
+ opts = DEFAULT_MARK_OPTIONS.dup.merge(opts)
68
+ notification.delivered = false
69
+ notification.delivered_at = nil
70
+ notification.failed = false
71
+ notification.failed_at = nil
72
+ notification.retries += 1
73
+ notification.deliver_after = deliver_after
74
+
75
+ return unless opts[:persist]
76
+
77
+ notification.save!(validate: false)
78
+ end
79
+
80
+ def mark_batch_retryable(notifications, deliver_after)
81
+ ids = []
82
+ notifications.each do |n|
83
+ mark_retryable(n, deliver_after, persist: false)
84
+ ids << n.id
85
+ end
86
+ mark_ids_retryable(ids, deliver_after)
87
+ end
88
+
89
+ def mark_ids_retryable(ids, deliver_after)
90
+ return if ids.empty?
91
+
92
+ Rpush::Client::Mongoid::Notification.in(id: ids).update_all(processing: false, delivered: false, delivered_at: nil, failed: false, failed_at: nil, deliver_after: deliver_after, '$inc' => { retries: 1 })
93
+ end
94
+
95
+ def create_apns_feedback(failed_at, device_token, app)
96
+ Rpush::Client::Mongoid::Apns::Feedback.create!(failed_at: failed_at, device_token: device_token, app: app)
97
+ end
98
+
99
+ def create_gcm_notification(attrs, data, registration_ids, deliver_after, app) # rubocop:disable ParameterLists
100
+ notification = Rpush::Client::Mongoid::Gcm::Notification.new
101
+ create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app)
102
+ end
103
+
104
+ def create_adm_notification(attrs, data, registration_ids, deliver_after, app) # rubocop:disable ParameterLists
105
+ notification = Rpush::Client::Mongoid::Adm::Notification.new
106
+ create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app)
107
+ end
108
+
109
+ def update_app(app)
110
+ app.save!
111
+ end
112
+
113
+ def update_notification(notification)
114
+ notification.save!
115
+ end
116
+
117
+ def release_connection
118
+ end
119
+
120
+ def reopen_log
121
+ end
122
+
123
+ def pending_delivery_count
124
+ ready_for_delivery.count
125
+ end
126
+
127
+ def translate_integer_notification_id(id)
128
+ Rpush::Client::Mongoid::Notification.find_by(integer_id: id).id
129
+ end
130
+
131
+ private
132
+
133
+ def ready_for_delivery
134
+ Rpush::Client::Mongoid::Notification.where(processing: false, delivered: false, failed: false).or({ deliver_after: nil }, :deliver_after.lt => Time.now)
135
+ end
136
+
137
+ def claim_notifications(relation)
138
+ ids = relation.map(:id)
139
+ relation.where('$isolated' => 1).in(id: ids).update_all(processing: true, processing_pid: Process.pid)
140
+ Rpush::Client::Mongoid::Notification.where(processing: true, processing_pid: Process.pid).in(id: ids).asc('created_at')
141
+ end
142
+
143
+ def create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app) # rubocop:disable ParameterLists
144
+ notification.assign_attributes(attrs)
145
+ notification.data = data
146
+ notification.registration_ids = registration_ids
147
+ notification.deliver_after = deliver_after
148
+ notification.app = app
149
+ notification.save!
150
+ notification
151
+ end
152
+ end
153
+ end
154
+ end
155
+ end
156
+
157
+ Rpush::Daemon::Store::Interface.check(Rpush::Daemon::Store::Mongoid)
@@ -49,7 +49,7 @@ module Rpush
49
49
  end
50
50
 
51
51
  def mark_ids_failed(ids, code, description, time)
52
- ids.each { |id| mark_failed(Rpush::Client::Redis::Apns::Notification.find(id), code, description, time) }
52
+ ids.each { |id| mark_failed(Rpush::Client::Redis::Notification.find(id), code, description, time) }
53
53
  end
54
54
 
55
55
  def mark_retryable(notification, deliver_after, opts = {})
@@ -75,7 +75,7 @@ module Rpush
75
75
  end
76
76
 
77
77
  def mark_ids_retryable(ids, deliver_after)
78
- ids.each { |id| mark_retryable(Rpush::Client::Redis::Apns::Notification.find(id), deliver_after) }
78
+ ids.each { |id| mark_retryable(Rpush::Client::Redis::Notification.find(id), deliver_after) }
79
79
  end
80
80
 
81
81
  def create_apns_feedback(failed_at, device_token, app)
@@ -115,6 +115,10 @@ module Rpush
115
115
  end
116
116
  end
117
117
 
118
+ def translate_integer_notification_id(id)
119
+ id
120
+ end
121
+
118
122
  private
119
123
 
120
124
  def create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app) # rubocop:disable ParameterLists
@@ -14,8 +14,7 @@ module Rpush
14
14
  warning << " #{msg}" if msg
15
15
  class_eval(<<-RUBY, __FILE__, __LINE__)
16
16
  def #{method_name}(*args, &blk)
17
- trace = "\n\nCALLED FROM:\n" + caller.join("\n")
18
- Rpush::Deprecation.warn(#{warning.inspect} + trace)
17
+ Rpush::Deprecation.warn_with_backtrace(#{warning.inspect})
19
18
  #{method_name_as_var}_without_warning(*args, &blk)
20
19
  end
21
20
  RUBY
@@ -16,5 +16,11 @@ module Rpush
16
16
  return if Rpush::Deprecation.muted?
17
17
  STDERR.puts "DEPRECATION WARNING: #{msg}"
18
18
  end
19
+
20
+ def self.warn_with_backtrace(msg)
21
+ return if Rpush::Deprecation.muted?
22
+ trace = "\n\nCALLED FROM:\n" + caller.join("\n")
23
+ warn(msg + trace)
24
+ end
19
25
  end
20
26
  end
data/lib/rpush/embed.rb CHANGED
@@ -2,6 +2,11 @@ module Rpush
2
2
  def self.embed(options = {})
3
3
  require 'rpush/daemon'
4
4
 
5
+ unless options.empty?
6
+ warning = "Passing configuration options directly to Rpush.embed is deprecated and will be removed from Rpush 2.5.0. Please setup configuration using Rpush.configure { |config| ... } before calling embed."
7
+ Rpush::Deprecation.warn_with_backtrace(warning)
8
+ end
9
+
5
10
  if @embed_thread
6
11
  STDERR.puts 'Rpush.embed can only be run once inside this process.'
7
12
  end
data/lib/rpush/logger.rb CHANGED
@@ -3,12 +3,9 @@ module Rpush
3
3
  attr_reader :internal_logger
4
4
 
5
5
  def initialize
6
- if Rpush.config.logger
7
- @internal_logger = Rpush.config.logger
8
- else
9
- @internal_logger = setup_logger(open_logfile)
10
- end
11
- rescue Errno::ENOENT, Errno::EPERM => e
6
+ @internal_logger = Rpush.config.logger || setup_logger(open_logfile)
7
+ @internal_logger.level = Rpush.config.log_level
8
+ rescue SystemCallError => e
12
9
  @internal_logger = nil
13
10
  error(e)
14
11
  error('Logging disabled.')
@@ -46,11 +43,11 @@ module Rpush
46
43
 
47
44
  def setup_logger(log)
48
45
  if ActiveSupport.const_defined?('BufferedLogger')
49
- logger = ActiveSupport::BufferedLogger.new(log, Rpush.config.log_level)
46
+ logger = ActiveSupport::BufferedLogger.new(log)
50
47
  logger.auto_flushing = auto_flushing
51
48
  logger
52
49
  else
53
- ActiveSupport::Logger.new(log, Rpush.config.log_level)
50
+ ActiveSupport::Logger.new(log)
54
51
  end
55
52
  end
56
53
 
data/lib/rpush/push.rb CHANGED
@@ -2,6 +2,11 @@ module Rpush
2
2
  def self.push(options = {})
3
3
  require 'rpush/daemon'
4
4
 
5
+ unless options.empty?
6
+ warning = "Passing configuration options directly to Rpush.push is deprecated and will be removed from Rpush 2.5.0. Please setup configuration using Rpush.configure { |config| ... } before calling push."
7
+ Rpush::Deprecation.warn_with_backtrace(warning)
8
+ end
9
+
5
10
  config = Rpush::ConfigurationWithoutDefaults.new
6
11
  options.each { |k, v| config.send("#{k}=", v) }
7
12
  config.push = true
data/lib/rpush/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rpush
2
- VERSION = '2.3.2'
2
+ VERSION = '2.4.0'
3
3
  end
@@ -3,7 +3,7 @@ begin
3
3
 
4
4
  desc 'Run cane to check quality metrics'
5
5
  Cane::RakeTask.new(:cane_quality) do |cane|
6
- cane.add_threshold 'coverage/covered_percent', :>=, 95
6
+ cane.add_threshold 'coverage/covered_percent', :>=, 80
7
7
  cane.no_style = false
8
8
  cane.style_measure = 1000
9
9
  cane.no_doc = true
data/lib/tasks/test.rake CHANGED
@@ -7,6 +7,11 @@ def cmd(str, clean_env = true)
7
7
  retval
8
8
  end
9
9
 
10
+ def add_ruby_dot_files
11
+ cmd("echo '#{RUBY_ENGINE}-#{RUBY_VERSION}' > .ruby-version")
12
+ cmd("echo 'rpush_test' > .ruby-gemset")
13
+ end
14
+
10
15
  desc 'Build Rails app bundled with Rpush'
11
16
  task :build_rails do
12
17
  rpush_root = Dir.pwd
@@ -20,10 +25,10 @@ task :build_rails do
20
25
 
21
26
  begin
22
27
  Dir.chdir(path)
28
+ add_ruby_dot_files
23
29
  cmd('echo "gem \'rake\'" >> Gemfile')
24
30
  cmd('echo "gem \'pg\'" >> Gemfile')
25
- cmd("echo \"gem 'rpush', :path => '#{rpush_root}'\" >> Gemfile")
26
- cmd('bundle install')
31
+ cmd("echo \"gem 'rpush', path: '#{rpush_root}'\" >> Gemfile")
27
32
 
28
33
  File.open('config/database.yml', 'w') do |fd|
29
34
  fd.write(<<-YML)
@@ -51,11 +56,11 @@ task :build_standalone do
51
56
 
52
57
  begin
53
58
  Dir.chdir(path)
59
+ add_ruby_dot_files
54
60
  cmd('echo "source \'https://rubygems.org\'" >> Gemfile')
55
61
  cmd('echo "gem \'rake\'" >> Gemfile')
56
62
  cmd('echo "gem \'rpush-redis\'" >> Gemfile')
57
- cmd("echo \"gem 'rpush', :path => '#{rpush_root}'\" >> Gemfile")
58
- cmd('bundle install')
63
+ cmd("echo \"gem 'rpush', path: '#{rpush_root}'\" >> Gemfile")
59
64
  ensure
60
65
  Dir.chdir(pwd)
61
66
  end
@@ -55,7 +55,8 @@ describe 'APNs' do
55
55
  end
56
56
 
57
57
  def fail_notification(notification)
58
- allow(ssl_socket).to receive_messages(read: [8, 4, notification.id].pack('ccN'))
58
+ id = (defined?(Mongoid) && notification.is_a?(Mongoid::Document)) ? notification.integer_id : notification.id
59
+ allow(ssl_socket).to receive_messages(read: [8, 4, id].pack('ccN'))
59
60
  enable_io_select
60
61
  end
61
62
 
@@ -11,12 +11,12 @@ RSpec.configure do |config|
11
11
  config.before(:each) do
12
12
  Modis.with_connection do |redis|
13
13
  redis.keys('rpush:*').each { |key| redis.del(key) }
14
- end
14
+ end if redis?
15
15
 
16
16
  Rpush.config.logger = ::Logger.new(STDOUT) if functional_example?(self.class.metadata)
17
17
  end
18
18
 
19
19
  config.after(:each) do
20
- DatabaseCleaner.clean if functional_example?(self.class.metadata)
20
+ DatabaseCleaner.clean if active_record? && functional_example?(self.class.metadata)
21
21
  end
22
22
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  ENV['RAILS_ENV'] = 'test'
2
- client = (ENV['CLIENT'] || :active_record).to_sym
2
+ def client
3
+ (ENV['CLIENT'] || :active_record).to_sym
4
+ end
3
5
 
4
6
  require 'bundler/setup'
5
7
  Bundler.require(:default)
@@ -21,7 +23,20 @@ require 'rpush/client/active_record'
21
23
  require 'rpush/daemon/store/active_record'
22
24
  require 'rpush/daemon/store/redis'
23
25
 
24
- require 'support/active_record_setup'
26
+ def active_record?
27
+ client == :active_record
28
+ end
29
+
30
+ def redis?
31
+ client == :redis
32
+ end
33
+
34
+ def mongoid?
35
+ client == :mongoid
36
+ end
37
+
38
+ require 'support/mongoid_setup' if mongoid?
39
+ require 'support/active_record_setup' if active_record?
25
40
 
26
41
  RPUSH_ROOT = '/tmp/rails_root'
27
42
 
@@ -31,10 +46,6 @@ end
31
46
 
32
47
  RPUSH_CLIENT = Rpush.config.client
33
48
 
34
- def active_record?
35
- Rpush.config.client == :active_record
36
- end
37
-
38
49
  path = File.join(File.dirname(__FILE__), 'support')
39
50
  TEST_CERT = File.read(File.join(path, 'cert_without_password.pem'))
40
51
  TEST_CERT_WITH_PASSWORD = File.read(File.join(path, 'cert_with_password.pem'))
@@ -43,7 +54,7 @@ def after_example_cleanup
43
54
  Rpush.logger = nil
44
55
  Rpush::Daemon.store = nil
45
56
  Rpush::Deprecation.muted do
46
- Rpush.config.set_defaults if Rpush.config.is_a?(Rpush::Configuration)
57
+ Rpush.config = nil
47
58
  Rpush.config.client = RPUSH_CLIENT
48
59
  end
49
60
  Rpush.plugins.values.each(&:unload)
@@ -0,0 +1,69 @@
1
+ development:
2
+ # Configure available database sessions. (required)
3
+ sessions:
4
+ # Defines the default session. (required)
5
+ default:
6
+ # Defines the name of the default database that Mongoid can connect to.
7
+ # (required).
8
+ database: rpush_development
9
+ # Provides the hosts the default session can connect to. Must be an array
10
+ # of host:port pairs. (required)
11
+ hosts:
12
+ - localhost:27017
13
+ options:
14
+ # Change the default write concern. (default = { w: 1 })
15
+ # write:
16
+ # w: 1
17
+
18
+ # Change the default consistency model to primary, secondary.
19
+ # 'secondary' will send reads to secondaries, 'primary' sends everything
20
+ # to master. (default: primary)
21
+ # read: secondary_preferred
22
+
23
+ # How many times Moped should attempt to retry an operation after
24
+ # failure. (default: The number of nodes in the cluster)
25
+ # max_retries: 20
26
+
27
+ # The time in seconds that Moped should wait before retrying an
28
+ # operation on failure. (default: 0.25)
29
+ # retry_interval: 0.25
30
+ # Configure Mongoid specific options. (optional)
31
+ options:
32
+ # Includes the root model name in json serialization. (default: false)
33
+ # include_root_in_json: false
34
+
35
+ # Include the _type field in serialization. (default: false)
36
+ # include_type_for_serialization: false
37
+
38
+ # Preload all models in development, needed when models use
39
+ # inheritance. (default: false)
40
+ # preload_models: false
41
+
42
+ # Protect id and type from mass assignment. (default: true)
43
+ # protect_sensitive_fields: true
44
+
45
+ # Raise an error when performing a #find and the document is not found.
46
+ # (default: true)
47
+ # raise_not_found_error: true
48
+
49
+ # Raise an error when defining a scope with the same name as an
50
+ # existing method. (default: false)
51
+ # scope_overwrite_exception: false
52
+
53
+ # Use Active Support's time zone in conversions. (default: true)
54
+ # use_activesupport_time_zone: true
55
+
56
+ # Ensure all times are UTC in the app side. (default: false)
57
+ # use_utc: false
58
+ test:
59
+ sessions:
60
+ default:
61
+ database: rpush_test
62
+ hosts:
63
+ - localhost:27017
64
+ options:
65
+ read: primary
66
+ # In the test environment we lower the retries and retry interval to
67
+ # low amounts for fast failures.
68
+ max_retries: 1
69
+ retry_interval: 0
@@ -0,0 +1,10 @@
1
+ require 'mongoid'
2
+
3
+ mongoid_yml = File.expand_path("config/mongoid.yml", File.dirname(__FILE__))
4
+ Mongoid.load!(mongoid_yml)
5
+
6
+ RSpec.configure do |config|
7
+ config.before(:each) do
8
+ Mongoid.purge!
9
+ end
10
+ end
@@ -55,4 +55,4 @@ describe Rpush::Client::ActiveRecord::Adm::App do
55
55
  expect(subject.access_token_expired?).to eq(false)
56
56
  end
57
57
  end
58
- end
58
+ end if active_record?
@@ -40,4 +40,4 @@ describe Rpush::Client::ActiveRecord::Adm::Notification do
40
40
  notification.expiry = 100
41
41
  expect(notification.as_json['expiresAfter']).to eq 100
42
42
  end
43
- end
43
+ end if active_record?
@@ -26,4 +26,4 @@ describe Rpush::Client::ActiveRecord::App do
26
26
  app.valid?
27
27
  expect(app.errors[:certificate]).to eq ['value must contain a certificate and a private key.']
28
28
  end
29
- end
29
+ end if active_record?
@@ -6,4 +6,4 @@ describe Rpush::Client::ActiveRecord::Apns::Feedback do
6
6
  expect(notification.valid?).to be_falsey
7
7
  expect(notification.errors[:device_token]).to include('is invalid')
8
8
  end
9
- end
9
+ end if active_record?