rapns_rails_2 3.5.1 → 3.6.1
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.
- checksums.yaml +7 -0
- data/README.md +2 -0
- data/lib/rapns/daemon/gcm/delivery.rb +4 -3
- data/lib/rapns/version.rb +1 -1
- metadata +46 -163
- data/config/database.yml +0 -44
- data/spec/support/cert_with_password.pem +0 -90
- data/spec/support/cert_without_password.pem +0 -59
- data/spec/support/simplecov_helper.rb +0 -13
- data/spec/support/simplecov_quality_formatter.rb +0 -8
- data/spec/tmp/.gitkeep +0 -0
- data/spec/unit/apns/app_spec.rb +0 -29
- data/spec/unit/apns/feedback_spec.rb +0 -9
- data/spec/unit/apns/notification_spec.rb +0 -215
- data/spec/unit/apns_feedback_spec.rb +0 -21
- data/spec/unit/app_spec.rb +0 -16
- data/spec/unit/configuration_spec.rb +0 -55
- data/spec/unit/daemon/apns/app_runner_spec.rb +0 -45
- data/spec/unit/daemon/apns/certificate_expired_error_spec.rb +0 -11
- data/spec/unit/daemon/apns/connection_spec.rb +0 -287
- data/spec/unit/daemon/apns/delivery_handler_spec.rb +0 -59
- data/spec/unit/daemon/apns/delivery_spec.rb +0 -101
- data/spec/unit/daemon/apns/disconnection_error_spec.rb +0 -18
- data/spec/unit/daemon/apns/feedback_receiver_spec.rb +0 -134
- data/spec/unit/daemon/app_runner_shared.rb +0 -83
- data/spec/unit/daemon/app_runner_spec.rb +0 -170
- data/spec/unit/daemon/batch_spec.rb +0 -219
- data/spec/unit/daemon/delivery_error_spec.rb +0 -13
- data/spec/unit/daemon/delivery_handler_collection_spec.rb +0 -37
- data/spec/unit/daemon/delivery_handler_shared.rb +0 -45
- data/spec/unit/daemon/feeder_spec.rb +0 -89
- data/spec/unit/daemon/gcm/app_runner_spec.rb +0 -19
- data/spec/unit/daemon/gcm/delivery_handler_spec.rb +0 -44
- data/spec/unit/daemon/gcm/delivery_spec.rb +0 -289
- data/spec/unit/daemon/interruptible_sleep_spec.rb +0 -68
- data/spec/unit/daemon/reflectable_spec.rb +0 -27
- data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +0 -114
- data/spec/unit/daemon/store/active_record_spec.rb +0 -281
- data/spec/unit/daemon_spec.rb +0 -157
- data/spec/unit/deprecatable_spec.rb +0 -32
- data/spec/unit/deprecation_spec.rb +0 -15
- data/spec/unit/embed_spec.rb +0 -50
- data/spec/unit/gcm/app_spec.rb +0 -4
- data/spec/unit/gcm/notification_spec.rb +0 -52
- data/spec/unit/logger_spec.rb +0 -180
- data/spec/unit/notification_shared.rb +0 -45
- data/spec/unit/notification_spec.rb +0 -4
- data/spec/unit/notifier_spec.rb +0 -52
- data/spec/unit/push_spec.rb +0 -44
- data/spec/unit/rapns_spec.rb +0 -9
- data/spec/unit/reflection_spec.rb +0 -30
- data/spec/unit/upgraded_spec.rb +0 -40
- data/spec/unit_spec_helper.rb +0 -137
data/spec/unit/rapns_spec.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
require File.expand_path("spec/unit_spec_helper")
|
2
|
-
|
3
|
-
describe Rapns do
|
4
|
-
it "lazy initializes the logger" do
|
5
|
-
Rapns.config.stub(:airbrake_notify => true, :foreground => true)
|
6
|
-
Rapns::Logger.should_receive(:new).with(:foreground => true, :airbrake_notify => true)
|
7
|
-
Rapns.logger
|
8
|
-
end
|
9
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require File.expand_path("spec/unit_spec_helper")
|
2
|
-
|
3
|
-
describe Rapns do
|
4
|
-
it 'yields reflections for configuration' do
|
5
|
-
did_yield = false
|
6
|
-
Rapns.reflect { |on| did_yield = true }
|
7
|
-
did_yield.should be_true
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'returns all reflections' do
|
11
|
-
Rapns.reflections.should be_kind_of(Rapns::Reflections)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe Rapns::Reflections do
|
16
|
-
it 'dispatches the given reflection' do
|
17
|
-
did_yield = false
|
18
|
-
Rapns.reflect do |on|
|
19
|
-
on.error { did_yield = true }
|
20
|
-
end
|
21
|
-
Rapns.reflections.__dispatch(:error)
|
22
|
-
did_yield.should be_true
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'raises an error when trying to dispatch and unknown reflection' do
|
26
|
-
expect do
|
27
|
-
Rapns.reflections.__dispatch(:unknown)
|
28
|
-
end.to raise_error(Rapns::Reflections::NoSuchReflectionError)
|
29
|
-
end
|
30
|
-
end
|
data/spec/unit/upgraded_spec.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require File.expand_path("spec/unit_spec_helper")
|
2
|
-
|
3
|
-
describe Rapns::Upgraded do
|
4
|
-
let(:logger) { double(:logger, :warn => nil) }
|
5
|
-
let(:config) { double(:config) }
|
6
|
-
|
7
|
-
before do
|
8
|
-
Rails.stub(:root).and_return('/rails_root')
|
9
|
-
Rapns.stub(:logger => logger, :config => config)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'prints a warning and exists if rapns has not been upgraded' do
|
13
|
-
Rapns::App.stub(:count).and_raise(ActiveRecord::StatementInvalid)
|
14
|
-
Rapns::Upgraded.stub(:puts)
|
15
|
-
Rapns::Upgraded.should_receive(:exit).with(1)
|
16
|
-
Rapns::Upgraded.check(:exit => true)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'does not exit if Rapns has not been upgraded and :exit is false' do
|
20
|
-
Rapns.config.stub(:embedded => true)
|
21
|
-
Rapns::App.stub(:count).and_raise(ActiveRecord::StatementInvalid)
|
22
|
-
Rapns::Upgraded.stub(:puts)
|
23
|
-
Rapns::Upgraded.should_not_receive(:exit)
|
24
|
-
Rapns::Upgraded.check(:exit => false)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'does not exit if Rapns has not been upgraded and is in push mode' do
|
28
|
-
Rapns.config.stub(:push => true)
|
29
|
-
Rapns::App.stub(:count).and_raise(ActiveRecord::StatementInvalid)
|
30
|
-
Rapns::Upgraded.stub(:puts)
|
31
|
-
Rapns::Upgraded.should_not_receive(:exit)
|
32
|
-
Rapns::Upgraded.check(:exit => false)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'warns if rapns.yml still exists' do
|
36
|
-
File.should_receive(:exists?).with('/rails_root/config/rapns/rapns.yml').and_return(true)
|
37
|
-
Rapns.logger.should_receive(:warn).with("Since 2.0.0 rapns uses command-line options and a Ruby based configuration file.\nPlease run 'rails g rapns' to generate a new configuration file into config/initializers.\nRemove config/rapns/rapns.yml to avoid this warning.\n")
|
38
|
-
Rapns::Upgraded.check(:exit => false)
|
39
|
-
end
|
40
|
-
end
|
data/spec/unit_spec_helper.rb
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
ENV['RAILS_ENV'] = 'test'
|
2
|
-
|
3
|
-
require 'bundler'
|
4
|
-
Bundler.require(:default)
|
5
|
-
|
6
|
-
require 'active_record'
|
7
|
-
|
8
|
-
unless ENV['TRAVIS'] && ENV['QUALITY'] == 'false'
|
9
|
-
begin
|
10
|
-
require './spec/support/simplecov_helper'
|
11
|
-
include SimpleCovHelper
|
12
|
-
start_simple_cov("unit-#{RUBY_VERSION}")
|
13
|
-
rescue LoadError
|
14
|
-
puts "Coverage disabled."
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
jruby = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
19
|
-
|
20
|
-
$adapter = ENV['ADAPTER'] || 'postgresql'
|
21
|
-
$adapter = 'jdbc' + $adapter if jruby
|
22
|
-
|
23
|
-
DATABASE_CONFIG = YAML.load_file(File.expand_path("../config/database.yml", File.dirname(__FILE__)))
|
24
|
-
|
25
|
-
if DATABASE_CONFIG[$adapter].nil?
|
26
|
-
puts "No such adapter '#{$adapter}'. Valid adapters are #{DATABASE_CONFIG.keys.join(', ')}."
|
27
|
-
exit 1
|
28
|
-
end
|
29
|
-
|
30
|
-
if ENV['TRAVIS']
|
31
|
-
DATABASE_CONFIG[$adapter]['username'] = 'postgres'
|
32
|
-
else
|
33
|
-
require 'etc'
|
34
|
-
username = $adapter =~ /mysql/ ? 'root' : Etc.getlogin
|
35
|
-
DATABASE_CONFIG[$adapter]['username'] = username
|
36
|
-
end
|
37
|
-
|
38
|
-
puts "Using #{$adapter} adapter."
|
39
|
-
|
40
|
-
ActiveRecord::Base.establish_connection(DATABASE_CONFIG[$adapter])
|
41
|
-
|
42
|
-
require 'generators/templates/create_rapns_notifications'
|
43
|
-
require 'generators/templates/create_rapns_feedback'
|
44
|
-
require 'generators/templates/add_alert_is_json_to_rapns_notifications'
|
45
|
-
require 'generators/templates/add_app_to_rapns'
|
46
|
-
require 'generators/templates/create_rapns_apps'
|
47
|
-
require 'generators/templates/add_gcm'
|
48
|
-
|
49
|
-
[CreateRapnsNotifications, CreateRapnsFeedback,
|
50
|
-
AddAlertIsJsonToRapnsNotifications, AddAppToRapns, CreateRapnsApps, AddGcm].each do |migration|
|
51
|
-
migration.down rescue ActiveRecord::StatementInvalid
|
52
|
-
migration.up
|
53
|
-
end
|
54
|
-
|
55
|
-
require 'database_cleaner'
|
56
|
-
DatabaseCleaner.strategy = :truncation
|
57
|
-
|
58
|
-
require 'rapns_rails_2'
|
59
|
-
require 'rapns/daemon'
|
60
|
-
|
61
|
-
Rapns::Notification.reset_column_information
|
62
|
-
Rapns::App.reset_column_information
|
63
|
-
Rapns::Apns::Feedback.reset_column_information
|
64
|
-
|
65
|
-
require 'spec'
|
66
|
-
require 'spec/mocks'
|
67
|
-
|
68
|
-
Spec::Runner.configure do |config|
|
69
|
-
# config.before :suite do
|
70
|
-
# PerfTools::CpuProfiler.start('/tmp/rapns_profile')
|
71
|
-
# end
|
72
|
-
# config.after :suite do
|
73
|
-
# PerfTools::CpuProfiler.stop
|
74
|
-
# end
|
75
|
-
|
76
|
-
config.before(:all) do
|
77
|
-
unless defined? RAILS_DEFAULT_LOGGER
|
78
|
-
logger = mock
|
79
|
-
logger.stub(:debug) { |a| puts "DEBUG:" + a }
|
80
|
-
logger.as_null_object
|
81
|
-
RAILS_DEFAULT_LOGGER = logger
|
82
|
-
end
|
83
|
-
ActiveRecord::Base.logger = RAILS_DEFAULT_LOGGER
|
84
|
-
|
85
|
-
ActiveRecord::Base.default_timezone = :utc
|
86
|
-
end
|
87
|
-
|
88
|
-
config.before(:each) do
|
89
|
-
DatabaseCleaner.clean
|
90
|
-
end
|
91
|
-
|
92
|
-
config.after(:each) do
|
93
|
-
Rapns.logger = nil
|
94
|
-
Rapns::Daemon.store = nil
|
95
|
-
Rapns::Deprecation.muted do
|
96
|
-
Rapns.config.set_defaults if Rapns.config.kind_of?(Rapns::Configuration)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def stub_constants(constants, &block)
|
102
|
-
defined_constants = {}
|
103
|
-
saved_constants = {}
|
104
|
-
|
105
|
-
constants.each do |constant, val|
|
106
|
-
defined = defined_constants[ constant ] = self.const_defined?(constant)
|
107
|
-
saved_constants[ constant ] = self.const_get( constant ) if defined
|
108
|
-
Kernel::silence_warnings { self.const_set( constant, val ) }
|
109
|
-
end
|
110
|
-
|
111
|
-
begin
|
112
|
-
block.call
|
113
|
-
ensure
|
114
|
-
constants.each do |constant, val|
|
115
|
-
if defined_constants[ constant ]
|
116
|
-
Kernel::silence_warnings { self.const_set( constant, saved_constants[ constant ] ) }
|
117
|
-
else
|
118
|
-
Kernel::silence_warnings { self.send(:remove_const, constant ) }
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
public :stub_constants
|
124
|
-
|
125
|
-
# a test certificate that contains both an X509 certificate and
|
126
|
-
# a private key, similar to those used for connecting to Apple
|
127
|
-
# push notification servers.
|
128
|
-
#
|
129
|
-
# Note that we cannot validate the certificate and private key
|
130
|
-
# because we are missing the certificate chain used to validate
|
131
|
-
# the certificate, and this is private to Apple. So if the app
|
132
|
-
# has a certificate and a private key in it, the only way to find
|
133
|
-
# out if it really is valid is to connect to Apple's servers.
|
134
|
-
|
135
|
-
path = File.join(File.dirname(__FILE__), 'support')
|
136
|
-
TEST_CERT = File.read(File.join(path, 'cert_without_password.pem'))
|
137
|
-
TEST_CERT_WITH_PASSWORD = File.read(File.join(path, 'cert_with_password.pem'))
|