Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Rails 7.2 and 8.0 #770

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

# The test job is a matrix of ruby/rails versions.
gha-job-authlogic-test:
name: Ruby ${{ matrix.ruby }}, ${{ matrix.gemfile }}.rb
name: Ruby ${{ matrix.ruby }}, Rails ${{ matrix.rails }}
runs-on: ubuntu-latest
services:
gha-service-authlogic-mysql:
Expand All @@ -50,28 +50,32 @@ jobs:
ports:
- 5432:5432
strategy:
fail-fast: false
# Unlike TravisCI, the database will not be part of the matrix. Each
# sub-job in the matrix tests all three databases. Alternatively, we could
# have set this up with each database as a separate job, but then we'd be
# duplicating the matrix configuration three times.
matrix:
gemfile:
["rails_5.2", "rails_6.0", "rails_6.1", "rails_7.0", "rails_7.1"]

# To keep matrix size down, only test highest and lowest rubies. In
# `.rubocopy.yml`, set `TargetRubyVersion`, to the lowest ruby version
# `.rubocop.yml`, set `TargetRubyVersion`, to the lowest ruby version
# tested here.
ruby: ["2.6", "2.7"]

ruby: ["2.6", "3.3"]
rails: ["5.2", "6.0", "6.1", "7.0", "7.1", "7.2", "8.0"]
exclude:
# rails 7 requires ruby >= 2.7.0
- ruby: "2.6"
gemfile: "rails_7.0"
rails: "7.0"
- ruby: "2.6"
rails: "7.1"
- ruby: "2.6"
gemfile: "rails_7.1"
rails: "7.2"
- ruby: "2.6"
rails: "8.0"
- ruby: "3.3"
rails: "5.2"
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
Expand All @@ -81,7 +85,7 @@ jobs:
gem install bundler -v 2.4.22
bundle install --jobs 4 --retry 3
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.rb
BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails }}.rb

# MySQL db was created above, sqlite will be created during test suite,
# when migrations occur, so we only need to create the postgres db. I
Expand All @@ -105,13 +109,13 @@ jobs:
- name: Test, sqlite
run: bundle exec rake test
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.rb
BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails }}.rb
DB: sqlite
- name: Test, mysql
run: bundle exec rake test
env:
BACKTRACE: 1
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.rb
BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails }}.rb
DB: mysql
AUTHLOGIC_DB_NAME: authlogic
AUTHLOGIC_DB_USER: root
Expand All @@ -121,7 +125,7 @@ jobs:
run: bundle exec rake test
env:
BACKTRACE: 1
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.rb
BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails }}.rb
DB: postgres
AUTHLOGIC_DB_NAME: authlogic
AUTHLOGIC_DB_USER: postgres
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added
- None
- Fixed
- None
- [#770](https://github.com/binarylogic/authlogic/pull/770) - Adds support for Rails 7.2 and 8.0

## 6.4.3 (2023-12-17)

Expand Down
18 changes: 13 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,20 @@ BUNDLE_GEMFILE=gemfiles/rails_7.0.rb bundle exec rake
# Rails 7.1
BUNDLE_GEMFILE=gemfiles/rails_7.1.rb bundle install
BUNDLE_GEMFILE=gemfiles/rails_7.1.rb bundle exec rake

# Rails 7.2
BUNDLE_GEMFILE=gemfiles/rails_7.2.rb bundle install
BUNDLE_GEMFILE=gemfiles/rails_7.2.rb bundle exec rake

# Rails 8.0
BUNDLE_GEMFILE=gemfiles/rails_8.0.rb bundle install
BUNDLE_GEMFILE=gemfiles/rails_8.0.rb bundle exec rake
```

To run a single test:

```
BUNDLE_GEMFILE=gemfiles/rails_6.0.rb \
BUNDLE_GEMFILE=gemfiles/rails_8.0.rb \
bundle exec ruby -I test path/to/test.rb
```

Expand All @@ -72,14 +80,14 @@ ruby –I test path/to/test.rb

```
mysql -e 'drop database authlogic; create database authlogic;' && \
DB=mysql BUNDLE_GEMFILE=gemfiles/rails_5.2.rb bundle exec rake
DB=mysql BUNDLE_GEMFILE=gemfiles/rails_8.0.rb bundle exec rake
```

### Test PostgreSQL

```
psql -c 'create database authlogic;' -U postgres
DB=postgres BUNDLE_GEMFILE=gemfiles/rails_6.0.rb bundle exec rake
DB=postgres BUNDLE_GEMFILE=gemfiles/rails_8.0.rb bundle exec rake
```

### Linting
Expand All @@ -88,13 +96,13 @@ Running `rake` also runs a linter, rubocop. Contributions must pass both
the linter and the tests. The linter can be run on its own.

```
BUNDLE_GEMFILE=gemfiles/rails_6.0.rb bundle exec rubocop
BUNDLE_GEMFILE=gemfiles/rails_8.0.rb bundle exec rubocop
```

To run the tests without linting, use `rake test`.

```
BUNDLE_GEMFILE=gemfiles/rails_6.0.rb bundle exec rake test
BUNDLE_GEMFILE=gemfiles/rails_8.0.rb bundle exec rake test
```

### Version Control Branches
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ in `authlogic/session/base.rb`.

| Version | branch | ruby | activerecord |
| ------- | ---------- | -------- | ------------- |
| 6.4.3 | 6-4-stable | >= 2.4.0 | >= 5.2, < 7.2 |
| 6.4.3 | 6-4-stable | >= 2.4.0 | >= 5.2, < 8.1 |
| 5.2 | 5-2-stable | >= 2.3.0 | >= 5.2, < 6.1 |
| 4.5 | 4-5-stable | >= 2.3.0 | >= 4.2, < 5.3 |
| 4.3 | 4-3-stable | >= 2.3.0 | >= 4.2, < 5.3 |
Expand Down
9 changes: 1 addition & 8 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ Rake::TestTask.new(:test) do |test|
test.verbose = false

# Set interpreter warning level to 2 (verbose)
#
# Warnings are set to 0 on TravisCI because it has a maximum
# log length of 4MB and the following warning is printed thousands of times:
#
# > ../postgresql/database_statements.rb:24:
# > warning: rb_tainted_str_new is deprecated and will be removed in Ruby 3.2.
warning_level = ENV.fetch("TRAVIS", "false") == "true" ? 0 : 2
test.ruby_opts += [format("-W%d", warning_level)]
test.ruby_opts << "-W2"
end

require "rubocop/rake_task"
Expand Down
17 changes: 7 additions & 10 deletions authlogic.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,21 @@ require "authlogic/version"
s.required_ruby_version = ">= 2.6.0"

# See doc/rails_support_in_authlogic_5.0.md
s.add_dependency "activemodel", [">= 5.2", "< 7.2"]
s.add_dependency "activerecord", [">= 5.2", "< 7.2"]
s.add_dependency "activesupport", [">= 5.2", "< 7.2"]
s.add_dependency "activemodel", [">= 5.2", "< 8.1"]
s.add_dependency "activerecord", [">= 5.2", "< 8.1"]
s.add_dependency "activesupport", [">= 5.2", "< 8.1"]
s.add_dependency "request_store", "~> 1.0"
s.add_development_dependency "bcrypt", "~> 3.1"
s.add_development_dependency "byebug", "~> 10.0"
s.add_development_dependency "coveralls", "~> 0.8.22"
s.add_development_dependency "byebug", "~> 11.1.3"
s.add_development_dependency "coveralls_reborn", "~> 0.28.0"
s.add_development_dependency "minitest", "< 5.19.0" # See https://github.com/binarylogic/authlogic/issues/766
s.add_development_dependency "minitest-reporters", "~> 1.3"
s.add_development_dependency "mysql2", "~> 0.5.2"
s.add_development_dependency "pg", "~> 1.1.4"
s.add_development_dependency "rake", "~> 13.0"
s.add_development_dependency "rubocop", "~> 0.80.1"
s.add_development_dependency "rubocop-performance", "~> 1.1"
s.add_development_dependency "scrypt", ">= 1.2", "< 4.0"
s.add_development_dependency "simplecov", "~> 0.16.1"
s.add_development_dependency "simplecov-console", "~> 0.4.2"
s.add_development_dependency "sqlite3", "~> 1.4.0"
s.add_development_dependency "simplecov", "~> 0.22.0"
s.add_development_dependency "simplecov-console", "~> 0.9.1"
s.add_development_dependency "timecop", "~> 0.7"

# To reduce gem size, only the minimum files are included.
Expand Down
7 changes: 5 additions & 2 deletions gemfiles/rails_5.2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
source "https://rubygems.org"
gemspec path: ".."

gem "activerecord", "~> 5.2.1"
gem "activesupport", "~> 5.2.1"
gem "activerecord", "~> 5.2.0"
gem "activesupport", "~> 5.2.0"
gem "mysql2", "~> 0.5.6"
gem "pg", "~> 1.5.8"
gem "sqlite3", "~> 1.4.0"
6 changes: 3 additions & 3 deletions gemfiles/rails_6.0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
source "https://rubygems.org"
gemspec path: ".."

# Rails 6 beta 1 has been released, so you might expect us to use exactly that
# version here, but it is still in flux, so we may continue using git for a
# while, maybe until RC 1 is released.
gem "activerecord", "~> 6.0.0"
gem "activesupport", "~> 6.0.0"
gem "mysql2", "~> 0.5.6"
gem "pg", "~> 1.5.8"
gem "sqlite3", "~> 1.4.0"
3 changes: 3 additions & 0 deletions gemfiles/rails_6.1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@

gem "activerecord", "~> 6.1.0"
gem "activesupport", "~> 6.1.0"
gem "mysql2", "~> 0.5.6"
gem "pg", "~> 1.5.8"
gem "sqlite3", "~> 1.4.0"
5 changes: 3 additions & 2 deletions gemfiles/rails_7.0.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# frozen_string_literal: true

git_source(:github) { |repo| "https://github.com/#{repo}.git" }

source "https://rubygems.org"
gemspec path: ".."

gem "activerecord", "~> 7.0.0"
gem "activesupport", "~> 7.0.0"
gem "mysql2", "~> 0.5.6"
gem "pg", "~> 1.5.8"
gem "sqlite3", "~> 1.6.0"
5 changes: 3 additions & 2 deletions gemfiles/rails_7.1.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# frozen_string_literal: true

git_source(:github) { |repo| "https://github.com/#{repo}.git" }

source "https://rubygems.org"
gemspec path: ".."

gem "activerecord", "~> 7.1.0"
gem "activesupport", "~> 7.1.0"
gem "mysql2", "~> 0.5.6"
gem "pg", "~> 1.5.8"
gem "sqlite3", "~> 1.6.0"
10 changes: 10 additions & 0 deletions gemfiles/rails_7.2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

source "https://rubygems.org"
gemspec path: ".."

gem "activerecord", "~> 7.2.0"
gem "activesupport", "~> 7.2.0"
gem "mysql2", "~> 0.5.6"
gem "pg", "~> 1.5.8"
gem "sqlite3", "~> 2.0.0"
10 changes: 10 additions & 0 deletions gemfiles/rails_8.0.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

source "https://rubygems.org"
gemspec path: ".."

gem "activerecord", "~> 8.0.0"
gem "activesupport", "~> 8.0.0"
gem "mysql2", "~> 0.5.6"
gem "pg", "~> 1.5.8"
gem "sqlite3", "~> 2.1.0"
2 changes: 1 addition & 1 deletion lib/authlogic/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def self.extended(klass)
private

def deprecate_authlogic_config(method_name)
::ActiveSupport::Deprecation.warn(
::ActiveSupport::Deprecation.new.warn(
format(E_USE_NORMAL_RAILS_VALIDATION, method_name)
)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/authlogic/session/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ def find(id = nil, priority_record = nil)

# @deprecated in favor of record_selection_method
def find_by_login_method(value = nil)
::ActiveSupport::Deprecation.warn(E_DPR_FIND_BY_LOGIN_METHOD)
::ActiveSupport::Deprecation.new.warn(E_DPR_FIND_BY_LOGIN_METHOD)
record_selection_method(value)
end
alias find_by_login_method= find_by_login_method
Expand Down Expand Up @@ -1791,7 +1791,7 @@ def exceeded_failed_logins_limit?

# @deprecated in favor of `self.class.record_selection_method`
def find_by_login_method
::ActiveSupport::Deprecation.warn(E_DPR_FIND_BY_LOGIN_METHOD)
::ActiveSupport::Deprecation.new.warn(E_DPR_FIND_BY_LOGIN_METHOD)
self.class.record_selection_method
end

Expand Down
12 changes: 6 additions & 6 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,16 @@
module ActiveSupport
class TestCase
include ActiveRecord::TestFixtures
self.fixture_path = File.dirname(__FILE__) + "/fixtures"

# use_transactional_fixtures= is deprecated and will be removed from Rails 5.1
# (use use_transactional_tests= instead)
if respond_to?(:use_transactional_tests=)
self.use_transactional_tests = false
# `fixture_path=` was deprecated in favor of
# `fixture_paths=` in Rails 7.1, removed in Rails 7.2.
if respond_to?(:fixture_paths=)
self.fixture_paths = [File.dirname(__FILE__) + "/fixtures"]
else
self.use_transactional_fixtures = false
self.fixture_path = File.dirname(__FILE__) + "/fixtures"
zhuravel marked this conversation as resolved.
Show resolved Hide resolved
end

self.use_transactional_tests = false
self.use_instantiated_fixtures = false
self.pre_loaded_fixtures = false
fixtures :all
Expand Down