rpush 2.0.1-java → 2.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +24 -18
- data/bin/rpush +1 -42
- data/lib/generators/rpush_config_generator.rb +7 -0
- data/lib/generators/{rpush_generator.rb → rpush_migration_generator.rb} +6 -11
- data/lib/generators/templates/rpush.rb +12 -12
- data/lib/generators/templates/rpush_2_0_0_updates.rb +2 -1
- data/lib/generators/templates/rpush_2_1_0_updates.rb +11 -0
- data/lib/rpush.rb +12 -4
- data/lib/rpush/apns_feedback.rb +1 -1
- data/lib/rpush/cli.rb +133 -0
- data/lib/rpush/client/active_model/apns/binary_notification_validator.rb +2 -2
- data/lib/rpush/client/active_model/apns/notification.rb +4 -1
- data/lib/rpush/client/active_model/notification.rb +0 -4
- data/lib/rpush/client/active_record/apns/notification.rb +0 -6
- data/lib/rpush/client/active_record/notification.rb +3 -2
- data/lib/rpush/client/redis/notification.rb +2 -0
- data/lib/rpush/configuration.rb +16 -24
- data/lib/rpush/daemon.rb +28 -1
- data/lib/rpush/daemon/app_runner.rb +6 -1
- data/lib/rpush/daemon/proc_title.rb +1 -1
- data/lib/rpush/daemon/signal_handler.rb +13 -3
- data/lib/rpush/daemon/store/active_record.rb +1 -1
- data/lib/rpush/deprecatable.rb +2 -1
- data/lib/rpush/embed.rb +1 -1
- data/lib/rpush/logger.rb +32 -19
- data/lib/rpush/push.rb +1 -1
- data/lib/rpush/version.rb +1 -1
- data/lib/tasks/quality.rake +1 -1
- data/lib/tasks/test.rake +12 -0
- data/spec/functional/apns_spec.rb +13 -11
- data/spec/functional_spec_helper.rb +1 -4
- data/spec/spec_helper.rb +4 -4
- data/spec/support/active_record_setup.rb +2 -1
- data/spec/unit/client/active_record/apns/notification_spec.rb +29 -3
- data/spec/unit/configuration_spec.rb +0 -7
- data/spec/unit/daemon/app_runner_spec.rb +1 -1
- data/spec/unit/daemon/signal_handler_spec.rb +1 -1
- data/spec/unit/daemon_spec.rb +1 -1
- data/spec/unit/deprecatable_spec.rb +1 -1
- data/spec/unit/logger_spec.rb +4 -4
- metadata +48 -3
data/lib/tasks/test.rake
CHANGED
@@ -21,8 +21,20 @@ namespace :test do
|
|
21
21
|
begin
|
22
22
|
Dir.chdir(path)
|
23
23
|
cmd('echo "gem \'rake\'" >> Gemfile')
|
24
|
+
cmd('echo "gem \'pg\'" >> Gemfile')
|
24
25
|
cmd("echo \"gem 'rpush', :path => '#{rpush_root}'\" >> Gemfile")
|
25
26
|
cmd('bundle install')
|
27
|
+
|
28
|
+
File.open('config/database.yml', 'w') do |fd|
|
29
|
+
fd.write(<<-YML)
|
30
|
+
development:
|
31
|
+
adapter: postgresql
|
32
|
+
database: rpush_rails_test
|
33
|
+
pool: 5
|
34
|
+
timeout: 5000
|
35
|
+
YML
|
36
|
+
end
|
37
|
+
|
26
38
|
cmd('bundle exec rails g rpush')
|
27
39
|
cmd('bundle exec rake db:migrate')
|
28
40
|
ensure
|
@@ -122,21 +122,23 @@ describe 'APNs' do
|
|
122
122
|
it 'does not mark prior notifications as failed' do
|
123
123
|
notifications.each { |n| wait_for_notification_to_deliver(n) }
|
124
124
|
fail_notification(notification2)
|
125
|
-
|
125
|
+
wait_for_notification_to_fail(notification2)
|
126
|
+
|
126
127
|
notification1.reload
|
127
128
|
notification1.delivered.should be_true
|
128
129
|
end
|
129
130
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
end
|
131
|
+
# Unreliable.
|
132
|
+
# it 'marks notifications following the failed one as retryable' do
|
133
|
+
# Rpush.config.push_poll = 1_000_000
|
134
|
+
#
|
135
|
+
# notifications.each { |n| wait_for_notification_to_deliver(n) }
|
136
|
+
# fail_notification(notification2)
|
137
|
+
#
|
138
|
+
# [notification3, notification4].each do |n|
|
139
|
+
# wait_for_notification_to_retry(n)
|
140
|
+
# end
|
141
|
+
# end
|
140
142
|
|
141
143
|
describe 'without an error response' do
|
142
144
|
it 'marks all notifications as failed' do
|
@@ -14,10 +14,7 @@ RSpec.configure do |config|
|
|
14
14
|
redis.keys('rpush:*').each { |key| redis.del(key) }
|
15
15
|
end
|
16
16
|
|
17
|
-
if functional_example?(example)
|
18
|
-
Rails.stub(root: File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp')))
|
19
|
-
Rpush.config.logger = ::Logger.new(STDOUT)
|
20
|
-
end
|
17
|
+
Rpush.config.logger = ::Logger.new(STDOUT) if functional_example?(example)
|
21
18
|
end
|
22
19
|
|
23
20
|
config.after(:each) do
|
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,7 @@ client = (ENV['CLIENT'] || :active_record).to_sym
|
|
4
4
|
require 'bundler/setup'
|
5
5
|
Bundler.require(:default)
|
6
6
|
|
7
|
-
|
7
|
+
if !ENV['TRAVIS'] || (ENV['TRAVIS'] && ENV['QUALITY'] == 'true')
|
8
8
|
begin
|
9
9
|
require './spec/support/simplecov_helper'
|
10
10
|
include SimpleCovHelper
|
@@ -23,11 +23,10 @@ require 'rpush/daemon/store/redis'
|
|
23
23
|
|
24
24
|
require 'support/active_record_setup'
|
25
25
|
|
26
|
-
|
26
|
+
RPUSH_ROOT = '/tmp/rails_root'
|
27
27
|
|
28
28
|
Rpush.configure do |config|
|
29
29
|
config.client = client
|
30
|
-
config.log_dir = RAILS_ROOT
|
31
30
|
end
|
32
31
|
|
33
32
|
RPUSH_CLIENT = Rpush.config.client
|
@@ -51,7 +50,8 @@ end
|
|
51
50
|
|
52
51
|
RSpec.configure do |config|
|
53
52
|
config.before(:each) do
|
54
|
-
|
53
|
+
Rpush.config.log_file = File.join(RPUSH_ROOT, 'rpush.log')
|
54
|
+
Rpush.stub(root: RPUSH_ROOT)
|
55
55
|
end
|
56
56
|
|
57
57
|
config.after(:each) do
|
@@ -28,8 +28,9 @@ ActiveRecord::Base.establish_connection(db_config[SPEC_ADAPTER])
|
|
28
28
|
|
29
29
|
require 'generators/templates/add_rpush'
|
30
30
|
require 'generators/templates/rpush_2_0_0_updates'
|
31
|
+
require 'generators/templates/rpush_2_1_0_updates'
|
31
32
|
|
32
|
-
migrations = [AddRpush, Rpush200Updates]
|
33
|
+
migrations = [AddRpush, Rpush200Updates, Rpush210Updates]
|
33
34
|
|
34
35
|
unless ENV['TRAVIS']
|
35
36
|
migrations.reverse.each do |m|
|
@@ -18,9 +18,9 @@ describe Rpush::Client::ActiveRecord::Apns::Notification do
|
|
18
18
|
|
19
19
|
it "should validate the length of the binary conversion of the notification" do
|
20
20
|
notification.device_token = "a" * 64
|
21
|
-
notification.alert = "way too long!" *
|
21
|
+
notification.alert = "way too long!" * 200
|
22
22
|
notification.valid?.should be_false
|
23
|
-
notification.errors[:base].include?("APN notification cannot be larger than
|
23
|
+
notification.errors[:base].include?("APN notification cannot be larger than 2048 bytes. Try condensing your alert and device attributes.").should be_true
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should default the sound to 'default'" do
|
@@ -143,6 +143,32 @@ describe Rpush::Client::ActiveRecord::Apns::Notification, 'content-available' do
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
+
describe Rpush::Client::ActiveRecord::Apns::Notification, 'url-args' do
|
147
|
+
let(:notification) { Rpush::Client::ActiveRecord::Apns::Notification.new }
|
148
|
+
|
149
|
+
it 'includes url-args in the payload' do
|
150
|
+
notification.url_args = ['url-arg-1']
|
151
|
+
notification.as_json['aps']['url-args'].should eq ['url-arg-1']
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'does not include url-args in the payload if not set' do
|
155
|
+
notification.as_json['aps'].key?('url-args').should be_false
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe Rpush::Client::ActiveRecord::Apns::Notification, 'category' do
|
160
|
+
let(:notification) { Rpush::Client::ActiveRecord::Apns::Notification.new }
|
161
|
+
|
162
|
+
it 'includes category in the payload' do
|
163
|
+
notification.category = 'INVITE_CATEGORY'
|
164
|
+
notification.as_json['aps']['category'].should eq 'INVITE_CATEGORY'
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'does not include category in the payload if not set' do
|
168
|
+
notification.as_json['aps'].key?('category').should be_false
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
146
172
|
describe Rpush::Client::ActiveRecord::Apns::Notification, 'to_binary' do
|
147
173
|
let(:notification) { Rpush::Client::ActiveRecord::Apns::Notification.new }
|
148
174
|
|
@@ -207,7 +233,7 @@ describe Rpush::Client::ActiveRecord::Apns::Notification, "bug #35" do
|
|
207
233
|
end
|
208
234
|
|
209
235
|
notification.to_binary(for_validation: true).bytesize.should be > 256
|
210
|
-
notification.
|
236
|
+
notification.payload.bytesize.should be < 256
|
211
237
|
notification.should be_valid
|
212
238
|
end
|
213
239
|
end
|
@@ -38,13 +38,6 @@ describe Rpush::Configuration do
|
|
38
38
|
config.pid_file.should eq '/tmp/rpush.pid'
|
39
39
|
end
|
40
40
|
|
41
|
-
it 'does not allow foreground to be set to false if the platform is JRuby' do
|
42
|
-
config.foreground = true
|
43
|
-
Rpush.stub(:jruby? => true)
|
44
|
-
config.foreground = false
|
45
|
-
config.foreground.should be_true
|
46
|
-
end
|
47
|
-
|
48
41
|
it 'delegate redis_options to Modis' do
|
49
42
|
Rpush.config.redis_options = { hi: :mom }
|
50
43
|
Modis.redis_options.should eq(hi: :mom)
|
@@ -61,7 +61,7 @@ describe Rpush::Daemon::AppRunner, 'enqueue' do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
describe Rpush::Daemon::AppRunner, 'start_app' do
|
64
|
-
let(:app) { double(id: 1, name: 'test') }
|
64
|
+
let(:app) { double(id: 1, name: 'test', connections: 1) }
|
65
65
|
let(:runner) { double(Rpush::Daemon::AppRunner, enqueue: nil, start: nil, stop: nil) }
|
66
66
|
let(:logger) { double(Rpush::Logger, error: nil, info: nil) }
|
67
67
|
|
@@ -73,7 +73,7 @@ describe Rpush::Daemon::SignalHandler do
|
|
73
73
|
describe 'error handing' do
|
74
74
|
let(:error) { StandardError.new('test') }
|
75
75
|
|
76
|
-
before { Rpush.stub(logger: double(error: nil)) }
|
76
|
+
before { Rpush.stub(logger: double(error: nil, info: nil)) }
|
77
77
|
|
78
78
|
it 'logs errors received when handling a signal' do
|
79
79
|
Rpush::Daemon::Synchronizer.stub(:sync).and_raise(error)
|
data/spec/unit/daemon_spec.rb
CHANGED
@@ -78,7 +78,7 @@ describe Rpush::Daemon, "when starting" do
|
|
78
78
|
it "logs an error if the PID file could not be written" do
|
79
79
|
Rpush.config.pid_file = '/rails_root/rpush.pid'
|
80
80
|
File.stub(:open).and_raise(Errno::ENOENT)
|
81
|
-
logger.should_receive(:error).with(
|
81
|
+
logger.should_receive(:error).with(%r{Failed to write PID to '/rails_root/rpush\.pid'})
|
82
82
|
Rpush::Daemon.start
|
83
83
|
end
|
84
84
|
|
@@ -21,7 +21,7 @@ describe Rpush::Deprecatable do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'warns the method is deprecated when called' do
|
24
|
-
Rpush::Deprecation.should_receive(:warn).with(
|
24
|
+
Rpush::Deprecation.should_receive(:warn).with(/deprecated_method is deprecated and will be removed from Rpush 4\.0\./)
|
25
25
|
klass.deprecated_method
|
26
26
|
end
|
27
27
|
|
data/spec/unit/logger_spec.rb
CHANGED
@@ -11,12 +11,12 @@ describe Rpush::Logger do
|
|
11
11
|
@logger_class = defined?(ActiveSupport::BufferedLogger) ? ActiveSupport::BufferedLogger : ActiveSupport::Logger
|
12
12
|
@logger = double(@logger_class.name, info: nil, error: nil, level: 0, auto_flushing: 1, :auto_flushing= => nil)
|
13
13
|
@logger_class.stub(:new).and_return(@logger)
|
14
|
-
Rails.logger
|
14
|
+
Rails.stub(logger: @logger)
|
15
15
|
File.stub(open: log)
|
16
16
|
FileUtils.stub(mkdir_p: nil)
|
17
17
|
STDERR.stub(:puts)
|
18
18
|
Rpush.config.foreground = true
|
19
|
-
Rpush.config.
|
19
|
+
Rpush.config.log_file = 'log/rpush.log'
|
20
20
|
end
|
21
21
|
|
22
22
|
it "disables logging if the log file cannot be opened" do
|
@@ -112,8 +112,8 @@ describe Rpush::Logger do
|
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'defaults auto_flushing to true if the Rails logger does not respond to auto_flushing' do
|
115
|
-
|
116
|
-
|
115
|
+
Rails.stub(logger: double(info: nil, error: nil, level: 0))
|
116
|
+
Rpush::Logger.new
|
117
117
|
@logger.auto_flushing.should be_true
|
118
118
|
end
|
119
119
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Ian Leitch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -52,6 +52,48 @@ dependencies:
|
|
52
52
|
version: '0'
|
53
53
|
prerelease: false
|
54
54
|
type: :runtime
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
prerelease: false
|
68
|
+
type: :runtime
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: railties
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
prerelease: false
|
82
|
+
type: :runtime
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: term-ansicolor
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
prerelease: false
|
96
|
+
type: :runtime
|
55
97
|
- !ruby/object:Gem::Dependency
|
56
98
|
name: jruby-openssl
|
57
99
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -91,7 +133,8 @@ files:
|
|
91
133
|
- CHANGELOG.md
|
92
134
|
- LICENSE
|
93
135
|
- README.md
|
94
|
-
- lib/generators/
|
136
|
+
- lib/generators/rpush_config_generator.rb
|
137
|
+
- lib/generators/rpush_migration_generator.rb
|
95
138
|
- lib/generators/templates/add_adm.rb
|
96
139
|
- lib/generators/templates/add_alert_is_json_to_rapns_notifications.rb
|
97
140
|
- lib/generators/templates/add_app_to_rapns.rb
|
@@ -105,8 +148,10 @@ files:
|
|
105
148
|
- lib/generators/templates/rename_rapns_to_rpush.rb
|
106
149
|
- lib/generators/templates/rpush.rb
|
107
150
|
- lib/generators/templates/rpush_2_0_0_updates.rb
|
151
|
+
- lib/generators/templates/rpush_2_1_0_updates.rb
|
108
152
|
- lib/rpush.rb
|
109
153
|
- lib/rpush/apns_feedback.rb
|
154
|
+
- lib/rpush/cli.rb
|
110
155
|
- lib/rpush/client/active_model.rb
|
111
156
|
- lib/rpush/client/active_model/adm/app.rb
|
112
157
|
- lib/rpush/client/active_model/adm/data_validator.rb
|