Skip to content

Commit

Permalink
Compatibility for Rails 5.2 (#105)
Browse files Browse the repository at this point in the history
* Compatibility for Rails 5.2

Why?
  Many projects are on older versions of Rails, and because some level of support
  for ActiveJob and ActionCable are found in version 5.2, there isn't too much
  fiddling around that's necessary to offer support for this environment.

How?
  From Rails 6 provide the ActionCable test adapter and test helpers, and also the
  Serializer support in ActiveJob, along with the DurationSerializer.  And use a
  freeze_time block for the one time-sensitive test that expects an exact five
  minute interval to elapse before sending notification.

* Use defaults from current Rails version in tests

* Reorganize polyfills

* Update gemfile lock

* Add SymbolSerializer for Rails 5.2 compatibility

* Rename duration_serializer.rb to serializers.rb

Co-authored-by: Chris Oliver <excid3@gmail.com>
  • Loading branch information
lorint and excid3 committed Mar 30, 2021
1 parent e25d304 commit 40099cd
Show file tree
Hide file tree
Showing 18 changed files with 723 additions and 17 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ jobs:
matrix:
ruby: ['2.7', '3.0']
gemfile:
- rails_5_2
- rails_6
- rails_6_1
- rails_master
exclude:
- ruby: '3.0'
gemfile: 'rails_5_2'
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
BUNDLE_PATH_RELATIVE_TO_CWD: true
Expand Down Expand Up @@ -48,9 +52,13 @@ jobs:
matrix:
ruby: ['2.7', '3.0']
gemfile:
- rails_5_2
- rails_6
- rails_6_1
- rails_master
exclude:
- ruby: '3.0'
gemfile: 'rails_5_2'
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
BUNDLE_PATH_RELATIVE_TO_CWD: true
Expand Down Expand Up @@ -91,9 +99,13 @@ jobs:
matrix:
ruby: ['2.7', '3.0']
gemfile:
- rails_5_2
- rails_6
- rails_6_1
- rails_master
exclude:
- ruby: '3.0'
gemfile: 'rails_5_2'
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
BUNDLE_PATH_RELATIVE_TO_CWD: true
Expand Down
4 changes: 4 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
appraise "rails-5-2" do
gem "rails", "~> 5.2.0"
end

appraise "rails-6" do
gem "rails", "~> 6.0.0"
end
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### Unreleased

* Provide compatibility layer for Rails 5.2 - @lorint and @excid3

# 1.3.2

* Add `queue` option for delivery methods - @iheanyi
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PATH
specs:
noticed (1.3.2)
http (>= 4.0.0)
rails (>= 6.0.0)
rails (>= 5.2.0)

GEM
remote: https://rubygems.org/
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,13 +471,13 @@ Rails 6.1+ can serialize Class and Module objects as arguments to ActiveJob. The
deliver_by DeliveryMethods::Discord
```

For Rails 6.0, you must pass strings of the class names in the `deliver_by` options.
For Rails 5.2 and 6.0, you must pass strings of the class names in the `deliver_by` options.

```ruby
deliver_by :discord, class: "DeliveryMethods::Discord"
```

We recommend the Rails 6.0 compatible options to prevent confusion.
We recommend using a string in order to prevent confusion.

### 📦 Database Model

Expand Down
9 changes: 9 additions & 0 deletions gemfiles/rails_5_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "byebug", group: [:development, :test]
gem "appraisal", branch: "fix-bundle-env", git: "https://github.com/excid3/appraisal.git"
gem "rails", "~> 5.2.0"

gemspec path: "../"
203 changes: 203 additions & 0 deletions gemfiles/rails_5_2.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
GIT
remote: https://github.com/excid3/appraisal.git
revision: 8bb003b273ae074356dc67b59ecc67c8ae2f3a27
branch: fix-bundle-env
specs:
appraisal (2.3.0)
bundler
rake
thor (>= 0.14.0)

PATH
remote: ..
specs:
noticed (1.3.2)
http (>= 4.0.0)
rails (>= 5.2.0)

GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.5)
actionpack (= 5.2.5)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.5)
actionpack (= 5.2.5)
actionview (= 5.2.5)
activejob (= 5.2.5)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.5)
actionview (= 5.2.5)
activesupport (= 5.2.5)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.5)
activesupport (= 5.2.5)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.5)
activesupport (= 5.2.5)
globalid (>= 0.3.6)
activemodel (5.2.5)
activesupport (= 5.2.5)
activerecord (5.2.5)
activemodel (= 5.2.5)
activesupport (= 5.2.5)
arel (>= 9.0)
activestorage (5.2.5)
actionpack (= 5.2.5)
activerecord (= 5.2.5)
marcel (~> 1.0.0)
activesupport (5.2.5)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
arel (9.0.0)
ast (2.4.2)
builder (3.2.4)
byebug (11.1.3)
concurrent-ruby (1.1.8)
crack (0.4.5)
rexml
crass (1.0.6)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
erubi (1.10.0)
ffi (1.15.0)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
globalid (0.4.2)
activesupport (>= 4.2.0)
hashdiff (1.0.1)
http (4.4.1)
addressable (~> 2.3)
http-cookie (~> 1.0)
http-form_data (~> 2.2)
http-parser (~> 1.2.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
http-form_data (2.3.0)
http-parser (1.2.3)
ffi-compiler (>= 1.0, < 2.0)
i18n (1.8.9)
concurrent-ruby (~> 1.0)
loofah (2.9.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (1.0.0)
method_source (1.0.0)
mini_mime (1.0.3)
mini_portile2 (2.5.0)
minitest (5.14.4)
mysql2 (0.5.3)
nio4r (2.5.7)
nokogiri (1.11.2)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
parallel (1.20.1)
parser (3.0.0.0)
ast (~> 2.4.1)
pg (1.2.3)
public_suffix (4.0.6)
racc (1.5.2)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.5)
actioncable (= 5.2.5)
actionmailer (= 5.2.5)
actionpack (= 5.2.5)
actionview (= 5.2.5)
activejob (= 5.2.5)
activemodel (= 5.2.5)
activerecord (= 5.2.5)
activestorage (= 5.2.5)
activesupport (= 5.2.5)
bundler (>= 1.3.0)
railties (= 5.2.5)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.2.5)
actionpack (= 5.2.5)
activesupport (= 5.2.5)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rainbow (3.0.0)
rake (13.0.3)
regexp_parser (2.1.1)
rexml (3.2.4)
rubocop (1.11.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.2.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.4.1)
parser (>= 2.7.1.5)
rubocop-performance (1.10.1)
rubocop (>= 0.90.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.11.0)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
standard (1.0.4)
rubocop (= 1.11.0)
rubocop-performance (= 1.10.1)
thor (1.1.0)
thread_safe (0.3.6)
tzinfo (1.2.9)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.7)
unicode-display_width (2.0.0)
webmock (3.12.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)

PLATFORMS
ruby

DEPENDENCIES
appraisal!
byebug
mysql2
noticed!
pg
rails (~> 5.2.0)
sqlite3
standard
webmock

BUNDLED WITH
2.2.15
2 changes: 1 addition & 1 deletion gemfiles/rails_6.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PATH
specs:
noticed (1.3.2)
http (>= 4.0.0)
rails (>= 6.0.0)
rails (>= 5.2.0)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_6_1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PATH
specs:
noticed (1.3.2)
http (>= 4.0.0)
rails (>= 6.0.0)
rails (>= 5.2.0)

GEM
remote: https://rubygems.org/
Expand Down
14 changes: 8 additions & 6 deletions gemfiles/rails_master.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GIT

GIT
remote: https://github.com/rails/rails.git
revision: 513cf351d4fbafe675eb0309930647afbcb92074
revision: 6675f6b785d9ea7f6650344fb98555fc5acb0a3d
branch: main
specs:
actioncable (7.0.0.alpha)
Expand Down Expand Up @@ -99,7 +99,7 @@ PATH
specs:
noticed (1.3.2)
http (>= 4.0.0)
rails (>= 6.0.0)
rails (>= 5.2.0)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -143,12 +143,12 @@ GEM
marcel (1.0.0)
method_source (1.0.0)
mini_mime (1.0.3)
mini_portile2 (2.5.0)
minitest (5.14.4)
mysql2 (0.5.3)
nio4r (2.5.7)
nokogiri (1.11.2)
mini_portile2 (~> 2.5.0)
nokogiri (1.11.2-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.11.2-x86_64-linux)
racc (~> 1.4)
parallel (1.20.1)
parser (3.0.0.0)
Expand Down Expand Up @@ -211,7 +211,9 @@ GEM
zeitwerk (2.4.2)

PLATFORMS
ruby
x86_64-darwin-19
x86_64-darwin-20
x86_64-linux

DEPENDENCIES
appraisal!
Expand Down
4 changes: 4 additions & 0 deletions lib/noticed/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ class Engine < ::Rails::Engine
include Noticed::HasNotifications
end
end

initializer "noticed.rails_5_2_support" do
require "rails_6_polyfills/base" if Rails::VERSION::MAJOR < 6
end
end
end
Loading

0 comments on commit 40099cd

Please sign in to comment.