Skip to content

Commit

Permalink
Drop support to all EOL rails versions
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Jun 9, 2023
1 parent 7e16300 commit 71b0468
Show file tree
Hide file tree
Showing 33 changed files with 45 additions and 472 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ jobs:
- gemfiles/Gemfile-rails-main
- gemfiles/Gemfile-rails-6-1
- gemfiles/Gemfile-rails-6-0
- gemfiles/Gemfile-rails-5-2
- gemfiles/Gemfile-rails-5-1
- gemfiles/Gemfile-rails-5-0
- gemfiles/Gemfile-rails-4-2
- gemfiles/Gemfile-rails-4-1
ruby:
- '3.2'
- '3.1'
Expand All @@ -35,50 +30,11 @@ jobs:
ruby: '3.1'
- gemfile: gemfiles/Gemfile-rails-6-0
env: DEVISE_ORM=mongoid
- gemfile: gemfiles/Gemfile-rails-5-2
ruby: '3.2'
- gemfile: gemfiles/Gemfile-rails-5-2
ruby: '3.1'
- gemfile: gemfiles/Gemfile-rails-5-2
ruby: '3.0'
- gemfile: gemfiles/Gemfile-rails-5-2
env: DEVISE_ORM=mongoid
- gemfile: gemfiles/Gemfile-rails-5-1
ruby: '3.2'
- gemfile: gemfiles/Gemfile-rails-5-1
ruby: '3.1'
- gemfile: gemfiles/Gemfile-rails-5-1
ruby: '3.0'
- gemfile: gemfiles/Gemfile-rails-5-1
env: DEVISE_ORM=mongoid
- gemfile: gemfiles/Gemfile-rails-5-0
ruby: '3.2'
- gemfile: gemfiles/Gemfile-rails-5-0
ruby: '3.1'
- gemfile: gemfiles/Gemfile-rails-5-0
ruby: '3.0'
- gemfile: gemfiles/Gemfile-rails-5-0
env: DEVISE_ORM=mongoid
- gemfile: gemfiles/Gemfile-rails-4-2
ruby: '3.2'
- gemfile: gemfiles/Gemfile-rails-4-2
ruby: '3.1'
- gemfile: gemfiles/Gemfile-rails-4-2
ruby: '3.0'
- gemfile: gemfiles/Gemfile-rails-4-1
ruby: '3.2'
- gemfile: gemfiles/Gemfile-rails-4-1
ruby: '3.1'
- gemfile: gemfiles/Gemfile-rails-4-1
ruby: '3.0'
runs-on: ubuntu-latest
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
steps:
- uses: actions/checkout@v3
- name: Setup Bundler 1.x for Rails 4.x
if: ${{ matrix.gemfile == 'gemfiles/Gemfile-rails-4-1' || matrix.gemfile == 'gemfiles/Gemfile-rails-4-2' }}
run: echo "BUNDLER_VERSION=1.17.3" >> $GITHUB_ENV
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
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

* Drop support to Ruby < 3.0
* Drop support to Rails < 6.0


### 4.9.2 - 2023-04-03
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
devise (4.9.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
railties (>= 6.0.0)
responders
warden (~> 1.2.3)

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,17 @@ Please note that the command output will show the variable value being used.
### BUNDLE_GEMFILE
We can use this variable to tell bundler what Gemfile it should use (instead of the one in the current directory).
Inside the [gemfiles](https://github.com/heartcombo/devise/tree/main/gemfiles) directory, we have one for each version of Rails we support. When you send us a pull request, it may happen that the test suite breaks using some of them. If that's the case, you can simulate the same environment using the `BUNDLE_GEMFILE` variable.
For example, if the tests broke using Ruby 3.0.0 and Rails 4.1, you can do the following:
For example, if the tests broke using Ruby 3.0.0 and Rails 6.0, you can do the following:
```bash
rbenv shell 3.0.0 # or rvm use 3.0.0
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bin/test
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-6.0-stable bundle install
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-6.0-stable bin/test
```

You can also combine both of them if the tests broke for Mongoid:
```bash
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable DEVISE_ORM=mongoid bin/test
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-6.0-stable bundle install
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-6.0-stable DEVISE_ORM=mongoid bin/test
```

### Running tests
Expand Down Expand Up @@ -172,7 +172,7 @@ Once you have solidified your understanding of Rails and authentication mechanis

## Getting started

Devise 4.0 works with Rails 4.1 onwards. Add the following line to your Gemfile:
Devise 4.0 works with Rails 6.0 onwards. Add the following line to your Gemfile:

```ruby
gem 'devise'
Expand Down Expand Up @@ -693,9 +693,9 @@ Alternatively, you can simply run the Devise generator.

Keep in mind that those models will have completely different routes. They **do not** and **cannot** share the same controller for sign in, sign out and so on. In case you want to have different roles sharing the same actions, we recommend that you use a role-based approach, by either providing a role column or using a dedicated gem for authorization.

### ActiveJob Integration
### Active Job Integration

If you are using Rails 4.2 and ActiveJob to deliver ActionMailer messages in the
If you are using Active Job to deliver Action Mailer messages in the
background through a queuing back-end, you can send Devise emails through your
existing queue by overriding the `send_devise_notification` method in your model.

Expand Down
2 changes: 1 addition & 1 deletion devise.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Gem::Specification.new do |s|
s.add_dependency("warden", "~> 1.2.3")
s.add_dependency("orm_adapter", "~> 0.1")
s.add_dependency("bcrypt", "~> 3.0")
s.add_dependency("railties", ">= 4.1.0")
s.add_dependency("railties", ">= 6.0.0")
s.add_dependency("responders")

s.post_install_message = %q{
Expand Down
40 changes: 0 additions & 40 deletions gemfiles/Gemfile-rails-4-1

This file was deleted.

39 changes: 0 additions & 39 deletions gemfiles/Gemfile-rails-4-2

This file was deleted.

31 changes: 0 additions & 31 deletions gemfiles/Gemfile-rails-5-0

This file was deleted.

24 changes: 0 additions & 24 deletions gemfiles/Gemfile-rails-5-1

This file was deleted.

24 changes: 0 additions & 24 deletions gemfiles/Gemfile-rails-5-2

This file was deleted.

6 changes: 0 additions & 6 deletions lib/devise/controllers/sign_in_out.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ def sign_out_all_scopes(lock = true)
private

def expire_data_after_sign_in!
# TODO: remove once Rails 5.2+ and forward are only supported.
# session.keys will return an empty array if the session is not yet loaded.
# This is a bug in both Rack and Rails.
# A call to #empty? forces the session to be loaded.
session.empty?

session.keys.grep(/^devise\./).each { |k| session.delete(k) }
end

Expand Down
19 changes: 1 addition & 18 deletions lib/devise/failure_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def scope_url
opts = {}

# Initialize script_name with nil to prevent infinite loops in
# authenticated mounted engines in rails 4.2 and 5.0
# authenticated mounted engines
opts[:script_name] = nil

route = route(scope)
Expand All @@ -152,13 +152,6 @@ def scope_url

if relative_url_root?
opts[:script_name] = relative_url_root

# We need to add the rootpath to `script_name` manually for applications that use a Rails
# version lower than 5.1. Otherwise, it is going to generate a wrong path for Engines
# that use Devise. Remove it when the support of Rails 5.0 is dropped.
elsif root_path_defined?(context) && !rails_51_and_up?
rootpath = context.routes.url_helpers.root_path
opts[:script_name] = rootpath.chomp('/') if rootpath.length > 1
end

if context.respond_to?(route)
Expand Down Expand Up @@ -274,15 +267,5 @@ def relative_url_root?
end

ActiveSupport.run_load_hooks(:devise_failure_app, self)

private

def root_path_defined?(context)
defined?(context.routes) && context.routes.url_helpers.respond_to?(:root_path)
end

def rails_51_and_up?
Rails.gem_version >= Gem::Version.new("5.1")
end
end
end
12 changes: 2 additions & 10 deletions lib/devise/models/authenticatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,16 @@ def devise_mailer
# # Deliver later with Active Job's `deliver_later`
# if message.respond_to?(:deliver_later)
# message.deliver_later
# # Remove once we move to Rails 4.2+ only, as `deliver` is deprecated.
# elsif message.respond_to?(:deliver_now)
# message.deliver_now
# else
# message.deliver
# message.deliver_now
# end
# end
#
# end
#
def send_devise_notification(notification, *args)
message = devise_mailer.send(notification, self, *args)
# Remove once we move to Rails 4.2+ only.
if message.respond_to?(:deliver_now)
message.deliver_now
else
message.deliver
end
message.deliver_now
end

def downcase_keys
Expand Down
Loading

0 comments on commit 71b0468

Please sign in to comment.