Skip to content

Commit b84c795

Browse files
committed
Drop Rails 5.2 support.
Move to web-push gem to fix OpenSSL 3.0 error. zaru/webpush#106 Fix various failing tests.
1 parent 9f46b33 commit b84c795

File tree

13 files changed

+64
-62
lines changed

13 files changed

+64
-62
lines changed

Appraisals

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@
77
# > the version from the appraisal takes precedence.
88
# > https://github.com/thoughtbot/appraisal
99

10-
appraise "rails-5.2" do
11-
gem "activesupport", "~> 5.2.0"
12-
13-
group :development do
14-
gem "rails", "~> 5.2.0"
15-
end
16-
end
17-
1810
appraise "rails-6.0" do
1911
gem "activesupport", "~> 6.0.0"
2012
# https://gist.github.com/yahonda/2776d8d7b6ea7045359f38c10449937b#rails-60z

Gemfile.lock

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PATH
1111
railties
1212
rainbow
1313
thor (>= 0.18.1, < 2.0)
14-
webpush (~> 1.0)
14+
web-push
1515

1616
GEM
1717
remote: https://rubygems.org/
@@ -46,6 +46,7 @@ GEM
4646
rake
4747
thor (>= 0.14.0)
4848
ast (2.4.2)
49+
base64 (0.2.0)
4950
builder (3.2.4)
5051
byebug (11.1.3)
5152
codeclimate-test-reporter (1.0.7)
@@ -59,7 +60,10 @@ GEM
5960
activerecord (>= 5.a)
6061
database_cleaner-core (~> 2.0.0)
6162
database_cleaner-core (2.0.1)
62-
diff-lcs (1.5.0)
63+
debug (1.9.2)
64+
irb (~> 1.10)
65+
reline (>= 0.3.8)
66+
diff-lcs (1.5.1)
6367
docile (1.4.0)
6468
erubi (1.12.0)
6569
faraday (2.9.0)
@@ -75,11 +79,15 @@ GEM
7579
multi_json (~> 1.11)
7680
os (>= 0.9, < 2.0)
7781
signet (>= 0.16, < 2.a)
78-
hkdf (0.3.0)
7982
http-2 (0.11.0)
8083
i18n (1.10.0)
8184
concurrent-ruby (~> 1.0)
82-
jwt (2.7.1)
85+
io-console (0.7.2)
86+
irb (1.14.0)
87+
rdoc (>= 4.0.0)
88+
reline (>= 0.4.2)
89+
jwt (2.8.2)
90+
base64
8391
loofah (2.22.0)
8492
crass (~> 1.0.2)
8593
nokogiri (>= 1.12.0)
@@ -94,7 +102,7 @@ GEM
94102
redis (>= 3.0)
95103
msgpack (1.4.5)
96104
multi_json (1.15.0)
97-
mysql2 (0.5.3)
105+
mysql2 (0.5.6)
98106
net-http (0.4.1)
99107
uri
100108
net-http-persistent (4.0.2)
@@ -104,11 +112,14 @@ GEM
104112
nokogiri (1.16.0)
105113
mini_portile2 (~> 2.8.2)
106114
racc (~> 1.4)
115+
openssl (3.2.0)
107116
os (1.1.4)
108117
parallel (1.21.0)
109118
parser (3.1.0.0)
110119
ast (~> 2.4.1)
111120
pg (1.2.3)
121+
psych (5.1.2)
122+
stringio
112123
public_suffix (5.0.4)
113124
racc (1.7.3)
114125
rack (2.2.8)
@@ -130,24 +141,28 @@ GEM
130141
zeitwerk (~> 2.5)
131142
rainbow (3.1.1)
132143
rake (13.0.6)
144+
rdoc (6.7.0)
145+
psych (>= 4.0.0)
133146
redis (4.6.0)
134147
regexp_parser (2.2.0)
148+
reline (0.5.9)
149+
io-console (~> 0.5)
135150
rexml (3.2.5)
136151
rpush-redis (1.2.0)
137152
modis (>= 3.0, < 5.0)
138-
rspec (3.4.0)
139-
rspec-core (~> 3.4.0)
140-
rspec-expectations (~> 3.4.0)
141-
rspec-mocks (~> 3.4.0)
142-
rspec-core (3.4.4)
143-
rspec-support (~> 3.4.0)
144-
rspec-expectations (3.4.0)
153+
rspec (3.13.0)
154+
rspec-core (~> 3.13.0)
155+
rspec-expectations (~> 3.13.0)
156+
rspec-mocks (~> 3.13.0)
157+
rspec-core (3.13.0)
158+
rspec-support (~> 3.13.0)
159+
rspec-expectations (3.13.1)
145160
diff-lcs (>= 1.2.0, < 2.0)
146-
rspec-support (~> 3.4.0)
147-
rspec-mocks (3.4.1)
161+
rspec-support (~> 3.13.0)
162+
rspec-mocks (3.13.1)
148163
diff-lcs (>= 1.2.0, < 2.0)
149-
rspec-support (~> 3.4.0)
150-
rspec-support (3.4.1)
164+
rspec-support (~> 3.13.0)
165+
rspec-support (3.13.1)
151166
rubocop (1.12.1)
152167
parallel (~> 1.10)
153168
parser (>= 3.0.0.0)
@@ -168,23 +183,25 @@ GEM
168183
faraday (>= 0.17.5, < 3.a)
169184
jwt (>= 1.5, < 3.0)
170185
multi_json (~> 1.10)
171-
simplecov (0.21.2)
186+
simplecov (0.22.0)
172187
docile (~> 1.1)
173188
simplecov-html (~> 0.11)
174189
simplecov_json_formatter (~> 0.1)
175190
simplecov-html (0.12.3)
176-
simplecov_json_formatter (0.1.3)
177-
sqlite3 (1.4.2)
191+
simplecov_json_formatter (0.1.4)
192+
sqlite3 (2.0.2)
193+
mini_portile2 (~> 2.8.0)
178194
stackprof (0.2.17)
195+
stringio (3.1.1)
179196
thor (1.2.1)
180197
timecop (0.9.4)
181198
tzinfo (2.0.4)
182199
concurrent-ruby (~> 1.0)
183200
unicode-display_width (2.1.0)
184201
uri (0.13.0)
185-
webpush (1.1.0)
186-
hkdf (~> 0.2)
202+
web-push (3.0.1)
187203
jwt (~> 2.0)
204+
openssl (~> 3.0)
188205
zeitwerk (2.6.12)
189206

190207
PLATFORMS
@@ -195,13 +212,14 @@ DEPENDENCIES
195212
byebug
196213
codeclimate-test-reporter
197214
database_cleaner
215+
debug
198216
modis (>= 2.0)
199217
mysql2
200218
pg
201219
rake
202220
rpush!
203221
rpush-redis (~> 1.0)
204-
rspec (~> 3.4.0)
222+
rspec
205223
rubocop (~> 1.12.0)
206224
rubocop-performance
207225
simplecov

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ This will run RSpec against all versions of Rails.
504504
You need to specify a `BUNDLE_GEMFILE` pointing to the gemfile before running the normal test command:
505505

506506
```
507-
BUNDLE_GEMFILE=gemfiles/rails_5.2.gemfile rspec spec/unit/apns_feedback_spec.rb
507+
BUNDLE_GEMFILE=gemfiles/rails_6.0.gemfile rspec spec/unit/apns_feedback_spec.rb
508508
```
509509

510510
##### Multiple database adapter support

gemfiles/rails_5.2.gemfile

Lines changed: 0 additions & 11 deletions
This file was deleted.

lib/rpush/client/active_model/fcm/notification.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ def apns_config
8484
end
8585

8686
def notification=(value)
87-
super(value.with_indifferent_access)
87+
value = value.with_indifferent_access if value.is_a?(Hash)
88+
super(value)
8889
end
8990

9091
def root_notification

lib/rpush/daemon/webpush/delivery.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require "webpush"
3+
require "web-push"
44

55
module Rpush
66
module Daemon
@@ -10,7 +10,7 @@ module Webpush
1010
# We just override #perform to inject the http instance that is managed
1111
# by Rpush.
1212
#
13-
class Request < ::Webpush::Request
13+
class Request < ::WebPush::Request
1414
def perform(http)
1515
req = Net::HTTP::Post.new(uri.request_uri, headers)
1616
req.body = body

rpush.gemspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ Gem::Specification.new do |s|
4040
s.add_runtime_dependency 'thor', ['>= 0.18.1', '< 2.0']
4141
s.add_runtime_dependency 'railties'
4242
s.add_runtime_dependency 'rainbow'
43-
s.add_runtime_dependency 'webpush', '~> 1.0'
43+
s.add_runtime_dependency 'web-push'
4444
s.add_runtime_dependency 'googleauth'
4545

46+
s.add_development_dependency 'debug'
4647
s.add_development_dependency 'rake'
47-
s.add_development_dependency 'rspec', '~> 3.4.0'
48+
s.add_development_dependency 'rspec'
4849
s.add_development_dependency 'database_cleaner'
4950
s.add_development_dependency 'timecop'
5051
s.add_development_dependency 'stackprof'

spec/functional/fcm_priority_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
notification.app_id = app.id
1818
notification.device_token = fake_device_token
1919
notification.data = { message: 'test' }
20+
notification.notification = { title: 'title' }
2021
notification.priority = priority
2122
notification.save!
2223

spec/spec_helper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def client
1313
end
1414
end
1515

16+
require 'debug'
1617
require 'timecop'
1718
require 'activerecord-jdbc-adapter' if defined? JRUBY_VERSION
1819

@@ -46,7 +47,7 @@ def redis?
4647
TEST_CERT = File.read(File.join(path, 'cert_without_password.pem'))
4748
TEST_CERT_WITH_PASSWORD = File.read(File.join(path, 'cert_with_password.pem'))
4849

49-
VAPID_KEYPAIR = Webpush.generate_key.to_hash.merge(subject: '[email protected]').to_json
50+
VAPID_KEYPAIR = WebPush.generate_key.to_hash.merge(subject: '[email protected]').to_json
5051

5152
def after_example_cleanup
5253
Rpush.logger = nil

spec/unit/client/shared/fcm/notification.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,19 @@
4949

5050
it 'includes content_available in the payload' do
5151
notification.content_available = true
52-
expect(notification.as_json['message']['content_available']).to eq true
53-
end
54-
55-
it 'fails if mutable_content is provided' do
56-
expect { notification.mutable_content = true }.to raise_error(ArgumentError)
52+
expect(notification.as_json["message"]["apns"]["payload"]["aps"]["content-available"]).to eq 1
5753
end
5854

5955
it 'sets the priority to high when set to high' do
56+
notification.notification = { title: "Title" }
6057
notification.priority = 'high'
6158
expect(notification.as_json['message']['android']['priority']).to eq 'high'
6259
expect(notification.as_json['message']['android']['notification']['notification_priority']).to eq 'PRIORITY_MAX'
6360
# TODO Add notification_priority
6461
end
6562

6663
it 'sets the priority to normal when set to normal' do
64+
notification.notification = { title: "Title" }
6765
notification.priority = 'normal'
6866
expect(notification.as_json['message']['android']['priority']).to eq 'normal'
6967
expect(notification.as_json['message']['android']['notification']['notification_priority']).to eq 'PRIORITY_DEFAULT'

0 commit comments

Comments
 (0)