Skip to content

Commit

Permalink
Fix for Devise 4.9.1 (devise-security#414)
Browse files Browse the repository at this point in the history
Devise removed the `activerecord51?` method, so we no longer use it.
Also start testing against modern Ruby and Rails versions.

Co-authored-by: Kevin Olbrich <[email protected]>
  • Loading branch information
olivier-thatch and olbrich authored Apr 14, 2023
1 parent 4585316 commit a3ddb92
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -53,7 +53,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -67,4 +67,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
8 changes: 6 additions & 2 deletions .github/workflows/test_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
fail-fast: false
matrix:
orm: [active_record, mongoid]
rails: ["5.2", "6.0", "6.1"]
ruby: ["2.7", "3.0", head]
rails: ["5.2", "6.0", "6.1", "7.0"]
ruby: ["2.7", "3.0", "3.1", "3.2", head]
exclude:
- orm: mongoid
rails: 6.0
Expand All @@ -23,6 +23,10 @@ jobs:
ruby: head
- rails: 5.2
ruby: 3.0
- rails: 5.2
ruby: 3.1
- rails: 5.2
ruby: 3.2
- rails: 5.2
ruby: head
steps:
Expand Down
11 changes: 11 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ appraise 'rails-6.1' do
# Taken from https://github.com/rails/rails/pull/42366
gem 'net-smtp', require: false
end

appraise 'rails-7.0' do
gem 'railties', '~> 7.0.0'
gem 'minitest-rails', '~> 7.0.0'
gem 'sprockets-rails', require: 'sprockets/rails'

# net-smtp, net-imap and net-pop were removed from default gems in Ruby 3.1, but is used by the `mail` gem.
# So we need to add them as dependencies until `mail` is fixed: https://github.com/mikel/mail/pull/1439
# Taken from https://github.com/rails/rails/pull/42366
gem 'net-smtp', require: false
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Devise Security

[![Build Status](https://travis-ci.org/devise-security/devise-security.svg?branch=master)](https://travis-ci.org/devise-security/devise-security)
[![Build Status](https://github.com/devise-security/devise-security/actions/workflows/test_suite.yml/badge.svg?branch=master)](https://github.com/devise-security/devise-security/actions/workflows/test_suite.yml)
[![Coverage Status](https://coveralls.io/repos/github/devise-security/devise-security/badge.svg?branch=master)](https://coveralls.io/github/devise-security/devise-security?branch=master)
[![Maintainability](https://api.codeclimate.com/v1/badges/ace7cd003a0db8bffa5a/maintainability)](https://codeclimate.com/github/devise-security/devise-security/maintainability)

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

source "https://rubygems.org"

gem "minitest-rails", "~> 7.0.0"
gem "railties", "~> 7.0.0"
gem "sprockets-rails", require: "sprockets/railtie"
gem "net-smtp", require: false

group :active_record do
gem "sqlite3"
end

group :mongoid do
gem "mongoid", "~> 7.3"

group :test do
gem "database_cleaner-mongoid", "~> 2.0"
end
end

group :test do
gem "rails-controller-testing"
end

gemspec path: "../"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class NotPersistedError < ActiveRecord::ActiveRecordError; end

module ActiveRecordPatch
extend ActiveSupport::Concern
unless Devise.activerecord51?

unless defined?(ActiveRecord) && ActiveRecord.gem_version >= Gem::Version.new("5.1.x")
# When the record was saved, was the +encrypted_password+ changed?
# @return [Boolean]
def saved_change_to_encrypted_password?
Expand Down

0 comments on commit a3ddb92

Please sign in to comment.