rapns 3.1.0-java → 3.2.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +6 -0
- data/README.md +26 -20
- data/config/database.yml +9 -0
- data/lib/generators/templates/add_gcm.rb +12 -12
- data/lib/rapns/apns/app.rb +2 -2
- data/lib/rapns/apns_feedback.rb +12 -0
- data/lib/rapns/daemon/apns/app_runner.rb +6 -17
- data/lib/rapns/daemon/apns/connection.rb +3 -3
- data/lib/rapns/daemon/apns/delivery.rb +2 -2
- data/lib/rapns/daemon/apns/delivery_handler.rb +19 -5
- data/lib/rapns/daemon/apns/feedback_receiver.rb +10 -6
- data/lib/rapns/daemon/app_runner.rb +14 -8
- data/lib/rapns/daemon/database_reconnectable.rb +6 -6
- data/lib/rapns/daemon/delivery_handler.rb +1 -1
- data/lib/rapns/daemon/feeder.rb +1 -1
- data/lib/rapns/daemon/gcm/delivery.rb +4 -4
- data/lib/rapns/daemon/interruptible_sleep.rb +2 -2
- data/lib/rapns/daemon/reflectable.rb +1 -1
- data/lib/rapns/daemon.rb +4 -40
- data/lib/rapns/logger.rb +66 -0
- data/lib/rapns/push.rb +6 -2
- data/lib/rapns/upgraded.rb +31 -0
- data/lib/rapns/version.rb +1 -1
- data/lib/rapns.rb +12 -0
- data/spec/acceptance_spec_helper.rb +2 -2
- data/spec/unit/apns/feedback_spec.rb +0 -3
- data/spec/unit/apns/notification_spec.rb +0 -3
- data/spec/unit/apns_feedback_spec.rb +16 -0
- data/spec/unit/app_spec.rb +1 -3
- data/spec/unit/daemon/apns/app_runner_spec.rb +9 -5
- data/spec/unit/daemon/apns/connection_spec.rb +2 -2
- data/spec/unit/daemon/apns/delivery_handler_spec.rb +14 -9
- data/spec/unit/daemon/apns/delivery_spec.rb +2 -3
- data/spec/unit/daemon/apns/feedback_receiver_spec.rb +6 -6
- data/spec/unit/daemon/app_runner_spec.rb +26 -6
- data/spec/unit/daemon/database_reconnectable_spec.rb +9 -7
- data/spec/unit/daemon/delivery_handler_shared.rb +3 -3
- data/spec/unit/daemon/feeder_spec.rb +2 -1
- data/spec/unit/daemon/gcm/app_runner_spec.rb +1 -1
- data/spec/unit/daemon/gcm/delivery_spec.rb +7 -7
- data/spec/unit/daemon/reflectable_spec.rb +2 -2
- data/spec/unit/daemon_spec.rb +25 -75
- data/spec/unit/embed_spec.rb +6 -0
- data/spec/unit/gcm/app_spec.rb +1 -2
- data/spec/unit/gcm/notification_spec.rb +0 -2
- data/spec/unit/{daemon/logger_spec.rb → logger_spec.rb} +19 -20
- data/spec/unit/notification_spec.rb +1 -3
- data/spec/unit/push_spec.rb +20 -9
- data/spec/unit/rapns_spec.rb +9 -0
- data/spec/unit/upgraded_spec.rb +46 -0
- data/spec/unit_spec_helper.rb +5 -2
- metadata +29 -15
- data/lib/rapns/daemon/logger.rb +0 -68
data/spec/unit/daemon_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'unit_spec_helper'
|
2
2
|
|
3
3
|
describe Rapns::Daemon, "when starting" do
|
4
4
|
module Rails; end
|
@@ -7,41 +7,43 @@ describe Rapns::Daemon, "when starting" do
|
|
7
7
|
let(:password) { stub }
|
8
8
|
let(:config) { stub(:pid_file => nil, :airbrake_notify => false,
|
9
9
|
:foreground => true, :embedded => false, :push => false) }
|
10
|
-
let(:logger) { stub(:info => nil, :error => nil, :warn => nil) }
|
10
|
+
let(:logger) { stub(:logger, :info => nil, :error => nil, :warn => nil) }
|
11
11
|
|
12
12
|
before do
|
13
13
|
Rapns.stub(:config => config)
|
14
|
+
Rapns::Logger.stub(:new => logger)
|
14
15
|
Rapns::Daemon::Feeder.stub(:start)
|
15
|
-
Rapns::Daemon::Logger.stub(:new).and_return(logger)
|
16
16
|
Rapns::Daemon::AppRunner.stub(:sync => nil, :stop => nil)
|
17
17
|
Rapns::Daemon.stub(:daemonize => nil, :reconnect_database => nil, :exit => nil, :puts => nil)
|
18
18
|
File.stub(:open)
|
19
19
|
Rails.stub(:root).and_return("/rails_root")
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
unless defined?(JRUBY_VERSION)
|
23
|
+
it "forks into a daemon if the foreground option is false" do
|
24
|
+
config.stub(:foreground => false)
|
25
|
+
ActiveRecord::Base.stub(:establish_connection)
|
26
|
+
Rapns::Daemon.should_receive(:daemonize)
|
27
|
+
Rapns::Daemon.start
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
it "does not fork into a daemon if the foreground option is true" do
|
31
|
+
config.stub(:foreground => true)
|
32
|
+
Rapns::Daemon.should_not_receive(:daemonize)
|
33
|
+
Rapns::Daemon.start
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
it "does not fork into a daemon if the push option is true" do
|
37
|
+
config.stub(:push => true)
|
38
|
+
Rapns::Daemon.should_not_receive(:daemonize)
|
39
|
+
Rapns::Daemon.start
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
it "does not fork into a daemon if the embedded option is true" do
|
43
|
+
config.stub(:embedded => true)
|
44
|
+
Rapns::Daemon.should_not_receive(:daemonize)
|
45
|
+
Rapns::Daemon.start
|
46
|
+
end
|
45
47
|
end
|
46
48
|
|
47
49
|
it 'sets up setup signal traps' do
|
@@ -55,12 +57,6 @@ describe Rapns::Daemon, "when starting" do
|
|
55
57
|
Rapns::Daemon.start
|
56
58
|
end
|
57
59
|
|
58
|
-
it 'does not setup signal traps when in push mode' do
|
59
|
-
config.stub(:push => true)
|
60
|
-
Rapns::Daemon.should_not_receive(:setup_signal_traps)
|
61
|
-
Rapns::Daemon.start
|
62
|
-
end
|
63
|
-
|
64
60
|
it "writes the process ID to the PID file" do
|
65
61
|
Rapns::Daemon.should_receive(:write_pid_file)
|
66
62
|
Rapns::Daemon.start
|
@@ -82,52 +78,6 @@ describe Rapns::Daemon, "when starting" do
|
|
82
78
|
Rapns::Daemon::AppRunner.should_receive(:sync)
|
83
79
|
Rapns::Daemon.start
|
84
80
|
end
|
85
|
-
|
86
|
-
it "sets up the logger" do
|
87
|
-
config.stub(:airbrake_notify => true)
|
88
|
-
Rapns::Daemon::Logger.should_receive(:new).with(:foreground => true, :airbrake_notify => true)
|
89
|
-
Rapns::Daemon.start
|
90
|
-
end
|
91
|
-
|
92
|
-
it "makes the logger accessible" do
|
93
|
-
Rapns::Daemon.start
|
94
|
-
Rapns::Daemon.logger.should == logger
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'prints a warning if there are no apps' do
|
98
|
-
Rapns::App.stub(:count => 0)
|
99
|
-
logger.should_receive(:warn).any_number_of_times
|
100
|
-
Rapns::Daemon.start
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'prints a warning exists if rapns has not been upgraded' do
|
104
|
-
Rapns::App.stub(:count).and_raise(ActiveRecord::StatementInvalid)
|
105
|
-
Rapns::Daemon.should_receive(:puts).any_number_of_times
|
106
|
-
Rapns::Daemon.should_receive(:exit).with(1)
|
107
|
-
Rapns::Daemon.start
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'does not exit if Rapns has not been upgraded and is embedded' do
|
111
|
-
config.stub(:embedded => true)
|
112
|
-
Rapns::App.stub(:count).and_raise(ActiveRecord::StatementInvalid)
|
113
|
-
Rapns::Daemon.should_receive(:puts).any_number_of_times
|
114
|
-
Rapns::Daemon.should_not_receive(:exit)
|
115
|
-
Rapns::Daemon.start
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'does not exit if Rapns has not been upgraded and is in push mode' do
|
119
|
-
config.stub(:push => true)
|
120
|
-
Rapns::App.stub(:count).and_raise(ActiveRecord::StatementInvalid)
|
121
|
-
Rapns::Daemon.should_receive(:puts).any_number_of_times
|
122
|
-
Rapns::Daemon.should_not_receive(:exit)
|
123
|
-
Rapns::Daemon.start
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'warns if rapns.yml still exists' do
|
127
|
-
File.should_receive(:exists?).with('/rails_root/config/rapns/rapns.yml').and_return(true)
|
128
|
-
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")
|
129
|
-
Rapns::Daemon.start
|
130
|
-
end
|
131
81
|
end
|
132
82
|
|
133
83
|
describe Rapns::Daemon, "when being shutdown" do
|
data/spec/unit/embed_spec.rb
CHANGED
@@ -23,6 +23,8 @@ describe Rapns, 'embed' do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe Rapns, 'shutdown' do
|
26
|
+
before { Rapns.config.embedded = true }
|
27
|
+
|
26
28
|
it 'shuts down the daemon' do
|
27
29
|
Rapns::Daemon.should_receive(:shutdown)
|
28
30
|
Rapns.shutdown
|
@@ -30,6 +32,8 @@ describe Rapns, 'shutdown' do
|
|
30
32
|
end
|
31
33
|
|
32
34
|
describe Rapns, 'sync' do
|
35
|
+
before { Rapns.config.embedded = true }
|
36
|
+
|
33
37
|
it 'syncs the AppRunner' do
|
34
38
|
Rapns::Daemon::AppRunner.should_receive(:sync)
|
35
39
|
Rapns.sync
|
@@ -37,6 +41,8 @@ describe Rapns, 'sync' do
|
|
37
41
|
end
|
38
42
|
|
39
43
|
describe Rapns, 'debug' do
|
44
|
+
before { Rapns.config.embedded = true }
|
45
|
+
|
40
46
|
it 'debugs the AppRunner' do
|
41
47
|
Rapns::Daemon::AppRunner.should_receive(:debug)
|
42
48
|
Rapns.debug
|
data/spec/unit/gcm/app_spec.rb
CHANGED
@@ -10,8 +10,6 @@ describe Rapns::Gcm::Notification do
|
|
10
10
|
let(:data_setter) { 'data=' }
|
11
11
|
let(:data_getter) { 'data' }
|
12
12
|
|
13
|
-
it { should validate_presence_of :registration_ids }
|
14
|
-
|
15
13
|
it "has a 'data' payload limit of 4096 bytes" do
|
16
14
|
notification.data = { :key => "a" * 4096 }
|
17
15
|
notification.valid?.should be_false
|
@@ -16,11 +16,11 @@ module HoptoadNotifier
|
|
16
16
|
end
|
17
17
|
|
18
18
|
module Airbrake
|
19
|
-
def self.
|
19
|
+
def self.notify_or_ignore(e)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe Rapns::
|
23
|
+
describe Rapns::Logger do
|
24
24
|
let(:log) { stub(:sync= => true) }
|
25
25
|
let(:config) { stub(:airbrake_notify => true) }
|
26
26
|
|
@@ -29,7 +29,6 @@ describe Rapns::Daemon::Logger do
|
|
29
29
|
@buffered_logger = mock("BufferedLogger", :info => nil, :error => nil, :level => 0, :auto_flushing => 1, :auto_flushing= => nil)
|
30
30
|
Rails.logger = @buffered_logger
|
31
31
|
ActiveSupport::BufferedLogger.stub(:new).and_return(@buffered_logger)
|
32
|
-
Rapns::Daemon.stub(:config => config)
|
33
32
|
File.stub(:open => log)
|
34
33
|
STDERR.stub(:puts)
|
35
34
|
end
|
@@ -38,32 +37,32 @@ describe Rapns::Daemon::Logger do
|
|
38
37
|
File.stub(:open).and_raise(Errno::ENOENT)
|
39
38
|
STDERR.should_receive(:puts).with(/No such file or directory/)
|
40
39
|
STDERR.should_receive(:puts).with(/Logging disabled/)
|
41
|
-
Rapns::
|
40
|
+
Rapns::Logger.new(:foreground => true)
|
42
41
|
end
|
43
42
|
|
44
43
|
it "should open the a log file in the Rails log directory" do
|
45
44
|
File.should_receive(:open).with('/rails_root/log/rapns.log', 'a')
|
46
|
-
Rapns::
|
45
|
+
Rapns::Logger.new(:foreground => true)
|
47
46
|
end
|
48
47
|
|
49
48
|
it 'sets sync mode on the log descriptor' do
|
50
49
|
log.should_receive(:sync=).with(true)
|
51
|
-
Rapns::
|
50
|
+
Rapns::Logger.new(:foreground => true)
|
52
51
|
end
|
53
52
|
|
54
53
|
it 'instantiates the BufferedLogger' do
|
55
54
|
ActiveSupport::BufferedLogger.should_receive(:new).with(log, Rails.logger.level)
|
56
|
-
Rapns::
|
55
|
+
Rapns::Logger.new(:foreground => true)
|
57
56
|
end
|
58
57
|
|
59
58
|
it "should print out the msg if running in the foreground" do
|
60
|
-
logger = Rapns::
|
59
|
+
logger = Rapns::Logger.new(:foreground => true)
|
61
60
|
STDOUT.should_receive(:puts).with(/hi mom/)
|
62
61
|
logger.info("hi mom")
|
63
62
|
end
|
64
63
|
|
65
64
|
it "should not print out the msg if not running in the foreground" do
|
66
|
-
logger = Rapns::
|
65
|
+
logger = Rapns::Logger.new(:foreground => false)
|
67
66
|
STDOUT.should_not_receive(:puts).with(/hi mom/)
|
68
67
|
logger.info("hi mom")
|
69
68
|
end
|
@@ -71,19 +70,19 @@ describe Rapns::Daemon::Logger do
|
|
71
70
|
it "should prefix log lines with the current time" do
|
72
71
|
now = Time.now
|
73
72
|
Time.stub(:now).and_return(now)
|
74
|
-
logger = Rapns::
|
73
|
+
logger = Rapns::Logger.new(:foreground => false)
|
75
74
|
@buffered_logger.should_receive(:info).with(/#{Regexp.escape("[#{now.to_s(:db)}]")}/)
|
76
75
|
logger.info("blah")
|
77
76
|
end
|
78
77
|
|
79
78
|
it "should prefix error logs with the ERROR label" do
|
80
|
-
logger = Rapns::
|
79
|
+
logger = Rapns::Logger.new(:foreground => false)
|
81
80
|
@buffered_logger.should_receive(:error).with(/#{Regexp.escape("[ERROR]")}/)
|
82
81
|
logger.error("eeek")
|
83
82
|
end
|
84
83
|
|
85
84
|
it "should prefix warn logs with the WARNING label" do
|
86
|
-
logger = Rapns::
|
85
|
+
logger = Rapns::Logger.new(:foreground => false)
|
87
86
|
@buffered_logger.should_receive(:warn).with(/#{Regexp.escape("[WARNING]")}/)
|
88
87
|
logger.warn("eeek")
|
89
88
|
end
|
@@ -91,7 +90,7 @@ describe Rapns::Daemon::Logger do
|
|
91
90
|
it "should handle an Exception instance" do
|
92
91
|
e = RuntimeError.new("hi mom")
|
93
92
|
e.stub(:backtrace => [])
|
94
|
-
logger = Rapns::
|
93
|
+
logger = Rapns::Logger.new(:foreground => false)
|
95
94
|
@buffered_logger.should_receive(:error).with(/RuntimeError, hi mom/)
|
96
95
|
logger.error(e)
|
97
96
|
end
|
@@ -99,7 +98,7 @@ describe Rapns::Daemon::Logger do
|
|
99
98
|
it "should notify Airbrake of the exception" do
|
100
99
|
e = RuntimeError.new("hi mom")
|
101
100
|
e.stub(:backtrace => [])
|
102
|
-
logger = Rapns::
|
101
|
+
logger = Rapns::Logger.new(:foreground => false, :airbrake_notify => true)
|
103
102
|
Airbrake.should_receive(:notify_or_ignore).with(e)
|
104
103
|
logger.error(e)
|
105
104
|
end
|
@@ -111,7 +110,7 @@ describe Rapns::Daemon::Logger do
|
|
111
110
|
|
112
111
|
after do
|
113
112
|
module Airbrake
|
114
|
-
def self.
|
113
|
+
def self.notify_or_ignore(e)
|
115
114
|
end
|
116
115
|
end
|
117
116
|
end
|
@@ -119,7 +118,7 @@ describe Rapns::Daemon::Logger do
|
|
119
118
|
it "should notify using HoptoadNotifier" do
|
120
119
|
e = RuntimeError.new("hi mom")
|
121
120
|
e.stub(:backtrace => [])
|
122
|
-
logger = Rapns::
|
121
|
+
logger = Rapns::Logger.new(:foreground => false, :airbrake_notify => true)
|
123
122
|
HoptoadNotifier.should_receive(:notify_or_ignore).with(e)
|
124
123
|
logger.error(e)
|
125
124
|
end
|
@@ -128,7 +127,7 @@ describe Rapns::Daemon::Logger do
|
|
128
127
|
it "should not notify Airbrake of the exception if the airbrake_notify option is false" do
|
129
128
|
e = RuntimeError.new("hi mom")
|
130
129
|
e.stub(:backtrace => [])
|
131
|
-
logger = Rapns::
|
130
|
+
logger = Rapns::Logger.new(:foreground => false, :airbrake_notify => false)
|
132
131
|
Airbrake.should_not_receive(:notify_or_ignore).with(e)
|
133
132
|
logger.error(e)
|
134
133
|
end
|
@@ -136,13 +135,13 @@ describe Rapns::Daemon::Logger do
|
|
136
135
|
it "should not notify Airbrake if explicitly disabled in the call to error" do
|
137
136
|
e = RuntimeError.new("hi mom")
|
138
137
|
e.stub(:backtrace => [])
|
139
|
-
logger = Rapns::
|
138
|
+
logger = Rapns::Logger.new(:foreground => false, :airbrake_notify => true)
|
140
139
|
Airbrake.should_not_receive(:notify_or_ignore).with(e)
|
141
140
|
logger.error(e, :airbrake_notify => false)
|
142
141
|
end
|
143
142
|
|
144
143
|
it "should not attempt to notify Airbrake of the error is not an Exception" do
|
145
|
-
logger = Rapns::
|
144
|
+
logger = Rapns::Logger.new(:foreground => false)
|
146
145
|
Airbrake.should_not_receive(:notify_or_ignore)
|
147
146
|
logger.error("string error message")
|
148
147
|
end
|
@@ -150,7 +149,7 @@ describe Rapns::Daemon::Logger do
|
|
150
149
|
it 'defaults auto_flushing to true if the Rails logger does not respond to auto_flushing' do
|
151
150
|
rails_logger = mock(:info => nil, :error => nil, :level => 0)
|
152
151
|
Rails.logger = rails_logger
|
153
|
-
logger = Rapns::
|
152
|
+
logger = Rapns::Logger.new({})
|
154
153
|
@buffered_logger.auto_flushing.should be_true
|
155
154
|
end
|
156
155
|
end
|
data/spec/unit/push_spec.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'unit_spec_helper'
|
2
2
|
|
3
3
|
describe Rapns, 'push' do
|
4
|
-
|
5
|
-
Rapns::
|
6
|
-
Rapns::Daemon.stub(:
|
4
|
+
before do
|
5
|
+
Rapns::Upgraded.stub(:check => nil)
|
6
|
+
Rapns::Daemon::AppRunner.stub(:sync => nil, :wait => nil)
|
7
|
+
Rapns::Daemon::Feeder.stub(:start => nil)
|
7
8
|
end
|
8
9
|
|
9
10
|
it 'sets the push config option to true' do
|
@@ -11,18 +12,28 @@ describe Rapns, 'push' do
|
|
11
12
|
Rapns.config.push.should be_true
|
12
13
|
end
|
13
14
|
|
14
|
-
it '
|
15
|
-
Rapns::Daemon.should_receive(:
|
15
|
+
it 'syncs the app runner' do
|
16
|
+
Rapns::Daemon::AppRunner.should_receive(:sync)
|
16
17
|
Rapns.push
|
17
18
|
end
|
18
19
|
|
19
|
-
it '
|
20
|
-
Rapns::Daemon.should_receive(:
|
20
|
+
it 'starts the feeder' do
|
21
|
+
Rapns::Daemon::Feeder.should_receive(:start)
|
22
|
+
Rapns.push
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'waits on the app runner' do
|
26
|
+
Rapns::Daemon::AppRunner.should_receive(:wait)
|
27
|
+
Rapns.push
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'stops on the app runner' do
|
31
|
+
Rapns::Daemon::AppRunner.should_receive(:stop)
|
21
32
|
Rapns.push
|
22
33
|
end
|
23
34
|
|
24
35
|
it 'overrides the default config options with those given as a hash' do
|
25
|
-
Rapns.config.
|
26
|
-
expect { Rapns.push(:
|
36
|
+
Rapns.config.batch_size = 20
|
37
|
+
expect { Rapns.push(:batch_size => 10) }.to change(Rapns.config, :batch_size).to(10)
|
27
38
|
end
|
28
39
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require '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
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'unit_spec_helper'
|
2
|
+
|
3
|
+
describe Rapns::Upgraded do
|
4
|
+
let(:logger) { stub(:logger, :warn => nil) }
|
5
|
+
let(:config) { stub(: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 if there are no apps' do
|
13
|
+
Rapns::App.stub(:count => 0)
|
14
|
+
Rapns.logger.should_receive(:warn).any_number_of_times
|
15
|
+
Rapns::Upgraded.check(:exit => false)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'prints a warning and exists if rapns has not been upgraded' do
|
19
|
+
Rapns::App.stub(:count).and_raise(ActiveRecord::StatementInvalid)
|
20
|
+
Rapns::Upgraded.should_receive(:puts).any_number_of_times
|
21
|
+
Rapns::Upgraded.should_receive(:exit).with(1)
|
22
|
+
Rapns::Upgraded.check(:exit => true)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'does not exit if Rapns has not been upgraded and :exit is false' do
|
26
|
+
Rapns.config.stub(:embedded => true)
|
27
|
+
Rapns::App.stub(:count).and_raise(ActiveRecord::StatementInvalid)
|
28
|
+
Rapns::Upgraded.should_receive(:puts).any_number_of_times
|
29
|
+
Rapns::Upgraded.should_not_receive(:exit)
|
30
|
+
Rapns::Upgraded.check(:exit => false)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'does not exit if Rapns has not been upgraded and is in push mode' do
|
34
|
+
Rapns.config.stub(:push => true)
|
35
|
+
Rapns::App.stub(:count).and_raise(ActiveRecord::StatementInvalid)
|
36
|
+
Rapns::Upgraded.should_receive(:puts).any_number_of_times
|
37
|
+
Rapns::Upgraded.should_not_receive(:exit)
|
38
|
+
Rapns::Upgraded.check(:exit => false)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'warns if rapns.yml still exists' do
|
42
|
+
File.should_receive(:exists?).with('/rails_root/config/rapns/rapns.yml').and_return(true)
|
43
|
+
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")
|
44
|
+
Rapns::Upgraded.check(:exit => false)
|
45
|
+
end
|
46
|
+
end
|
data/spec/unit_spec_helper.rb
CHANGED
@@ -49,7 +49,6 @@ end
|
|
49
49
|
require 'bundler'
|
50
50
|
Bundler.require(:default)
|
51
51
|
|
52
|
-
require 'shoulda'
|
53
52
|
require 'database_cleaner'
|
54
53
|
|
55
54
|
DatabaseCleaner.strategy = :truncation
|
@@ -69,7 +68,11 @@ RSpec.configure do |config|
|
|
69
68
|
# PerfTools::CpuProfiler.stop
|
70
69
|
# end
|
71
70
|
|
72
|
-
config.before(:each)
|
71
|
+
config.before(:each) do
|
72
|
+
DatabaseCleaner.clean
|
73
|
+
end
|
74
|
+
|
75
|
+
config.after(:each) { Rapns.logger = nil }
|
73
76
|
end
|
74
77
|
|
75
78
|
# a test certificate that contains both an X509 certificate and
|
metadata
CHANGED
@@ -2,26 +2,26 @@
|
|
2
2
|
name: rapns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 3.
|
5
|
+
version: 3.2.0
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Ian Leitch
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
16
16
|
version_requirements: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '1.0'
|
21
21
|
none: false
|
22
22
|
requirement: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
27
|
none: false
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
name: net-http-persistent
|
32
32
|
version_requirements: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
|
-
- -
|
34
|
+
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: !binary |-
|
37
37
|
MA==
|
38
38
|
none: false
|
39
39
|
requirement: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: !binary |-
|
44
44
|
MA==
|
@@ -49,14 +49,14 @@ dependencies:
|
|
49
49
|
name: jruby-openssl
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: !binary |-
|
55
55
|
MA==
|
56
56
|
none: false
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: !binary |-
|
62
62
|
MA==
|
@@ -67,14 +67,14 @@ dependencies:
|
|
67
67
|
name: activerecord-jdbc-adapter
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
|
-
- -
|
70
|
+
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: !binary |-
|
73
73
|
MA==
|
74
74
|
none: false
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
|
-
- -
|
77
|
+
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: !binary |-
|
80
80
|
MA==
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/rapns/apns/feedback.rb
|
108
108
|
- lib/rapns/apns/notification.rb
|
109
109
|
- lib/rapns/apns/required_fields_validator.rb
|
110
|
+
- lib/rapns/apns_feedback.rb
|
110
111
|
- lib/rapns/app.rb
|
111
112
|
- lib/rapns/configuration.rb
|
112
113
|
- lib/rapns/daemon.rb
|
@@ -129,7 +130,6 @@ files:
|
|
129
130
|
- lib/rapns/daemon/gcm/delivery.rb
|
130
131
|
- lib/rapns/daemon/gcm/delivery_handler.rb
|
131
132
|
- lib/rapns/daemon/interruptible_sleep.rb
|
132
|
-
- lib/rapns/daemon/logger.rb
|
133
133
|
- lib/rapns/daemon/reflectable.rb
|
134
134
|
- lib/rapns/deprecatable.rb
|
135
135
|
- lib/rapns/deprecation.rb
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lib/rapns/gcm/notification.rb
|
140
140
|
- lib/rapns/gcm/payload_data_size_validator.rb
|
141
141
|
- lib/rapns/gcm/registration_ids_count_validator.rb
|
142
|
+
- lib/rapns/logger.rb
|
142
143
|
- lib/rapns/multi_json_helper.rb
|
143
144
|
- lib/rapns/notification.rb
|
144
145
|
- lib/rapns/patches.rb
|
@@ -146,6 +147,7 @@ files:
|
|
146
147
|
- lib/rapns/patches/rails/3.1.1/postgresql_adapter.rb
|
147
148
|
- lib/rapns/push.rb
|
148
149
|
- lib/rapns/reflection.rb
|
150
|
+
- lib/rapns/upgraded.rb
|
149
151
|
- lib/rapns/version.rb
|
150
152
|
- lib/tasks/cane.rake
|
151
153
|
- lib/tasks/test.rake
|
@@ -159,6 +161,7 @@ files:
|
|
159
161
|
- spec/unit/apns/app_spec.rb
|
160
162
|
- spec/unit/apns/feedback_spec.rb
|
161
163
|
- spec/unit/apns/notification_spec.rb
|
164
|
+
- spec/unit/apns_feedback_spec.rb
|
162
165
|
- spec/unit/app_spec.rb
|
163
166
|
- spec/unit/configuration_spec.rb
|
164
167
|
- spec/unit/daemon/apns/app_runner_spec.rb
|
@@ -178,7 +181,6 @@ files:
|
|
178
181
|
- spec/unit/daemon/gcm/delivery_handler_spec.rb
|
179
182
|
- spec/unit/daemon/gcm/delivery_spec.rb
|
180
183
|
- spec/unit/daemon/interruptible_sleep_spec.rb
|
181
|
-
- spec/unit/daemon/logger_spec.rb
|
182
184
|
- spec/unit/daemon/reflectable_spec.rb
|
183
185
|
- spec/unit/daemon_spec.rb
|
184
186
|
- spec/unit/deprecatable_spec.rb
|
@@ -186,10 +188,13 @@ files:
|
|
186
188
|
- spec/unit/embed_spec.rb
|
187
189
|
- spec/unit/gcm/app_spec.rb
|
188
190
|
- spec/unit/gcm/notification_spec.rb
|
191
|
+
- spec/unit/logger_spec.rb
|
189
192
|
- spec/unit/notification_shared.rb
|
190
193
|
- spec/unit/notification_spec.rb
|
191
194
|
- spec/unit/push_spec.rb
|
195
|
+
- spec/unit/rapns_spec.rb
|
192
196
|
- spec/unit/reflection_spec.rb
|
197
|
+
- spec/unit/upgraded_spec.rb
|
193
198
|
- spec/unit_spec_helper.rb
|
194
199
|
- bin/rapns
|
195
200
|
homepage: https://github.com/ileitch/rapns
|
@@ -200,15 +205,21 @@ require_paths:
|
|
200
205
|
- lib
|
201
206
|
required_ruby_version: !ruby/object:Gem::Requirement
|
202
207
|
requirements:
|
203
|
-
- -
|
208
|
+
- - ">="
|
204
209
|
- !ruby/object:Gem::Version
|
210
|
+
segments:
|
211
|
+
- 0
|
212
|
+
hash: 2
|
205
213
|
version: !binary |-
|
206
214
|
MA==
|
207
215
|
none: false
|
208
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
217
|
requirements:
|
210
|
-
- -
|
218
|
+
- - ">="
|
211
219
|
- !ruby/object:Gem::Version
|
220
|
+
segments:
|
221
|
+
- 0
|
222
|
+
hash: 2
|
212
223
|
version: !binary |-
|
213
224
|
MA==
|
214
225
|
none: false
|
@@ -229,6 +240,7 @@ test_files:
|
|
229
240
|
- spec/unit/apns/app_spec.rb
|
230
241
|
- spec/unit/apns/feedback_spec.rb
|
231
242
|
- spec/unit/apns/notification_spec.rb
|
243
|
+
- spec/unit/apns_feedback_spec.rb
|
232
244
|
- spec/unit/app_spec.rb
|
233
245
|
- spec/unit/configuration_spec.rb
|
234
246
|
- spec/unit/daemon/apns/app_runner_spec.rb
|
@@ -248,7 +260,6 @@ test_files:
|
|
248
260
|
- spec/unit/daemon/gcm/delivery_handler_spec.rb
|
249
261
|
- spec/unit/daemon/gcm/delivery_spec.rb
|
250
262
|
- spec/unit/daemon/interruptible_sleep_spec.rb
|
251
|
-
- spec/unit/daemon/logger_spec.rb
|
252
263
|
- spec/unit/daemon/reflectable_spec.rb
|
253
264
|
- spec/unit/daemon_spec.rb
|
254
265
|
- spec/unit/deprecatable_spec.rb
|
@@ -256,8 +267,11 @@ test_files:
|
|
256
267
|
- spec/unit/embed_spec.rb
|
257
268
|
- spec/unit/gcm/app_spec.rb
|
258
269
|
- spec/unit/gcm/notification_spec.rb
|
270
|
+
- spec/unit/logger_spec.rb
|
259
271
|
- spec/unit/notification_shared.rb
|
260
272
|
- spec/unit/notification_spec.rb
|
261
273
|
- spec/unit/push_spec.rb
|
274
|
+
- spec/unit/rapns_spec.rb
|
262
275
|
- spec/unit/reflection_spec.rb
|
276
|
+
- spec/unit/upgraded_spec.rb
|
263
277
|
- spec/unit_spec_helper.rb
|