Skip to content
Merged
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
46 changes: 25 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:
matrix:
include:
#
# Rails 4.x branch
# Rails 4.x series
#
# Rails 4.2 compatible versions
- ruby: 2.5
rails: 4.2.11.3
devise: 4.8.1

#
# Rails 5.x branch
# Rails 5.x series
#
# Rails 5.0 compatible versions
- ruby: 2.5 # We should use 2.4 but Nokogiri requires 2.5
Expand All @@ -39,7 +39,7 @@ jobs:
devise: 4.8.1

#
# Rails 6.x branch
# Rails 6.x series
#
# Rails 6.0 compatible versions
- ruby: 2.6
Expand All @@ -57,6 +57,24 @@ jobs:
- ruby: 3.1
rails: 6.1.7.10
devise: 4.9.4

#
# Rails 7.x series
#
- ruby: 3.1
rails: 7.0.8.7
devise: 4.9.4
- ruby: 3.2
rails: 7.0.8.7
devise: 4.9.4
# This can't work since the `test/rails_app/` needs to be upgraded
# See https://github.com/Pharmony/devise_gauth/issues/12
# - ruby: 3.2
# rails: 7.1.5.1
# devise: 4.9.4
# - ruby: 3.3
# rails: 7.2.2.1
# devise: 4.9.4
runs-on: ubuntu-latest
name: RSpec suite (Ruby ${{ matrix.ruby }}/Rails ${{ matrix.rails }}/Devise ${{ matrix.devise }})
env:
Expand All @@ -67,28 +85,14 @@ jobs:
EARTHLY_RUBY_VERSION: ${{ matrix.ruby }}
FORCE_COLOR: 1
steps:
- uses: actions/checkout@v3
- name: Put back the git branch into git (Earthly uses it for tagging)
run: |
branch=""
if [ -n "$GITHUB_HEAD_REF" ]; then
branch="$GITHUB_HEAD_REF"
else
branch="${GITHUB_REF##*/}"
fi
git checkout -b "$branch" || true
- uses: earthly/actions-setup@v1
with:
version: v0.8.0
- uses: actions/checkout@v4
- name: Docker Login
run: docker login --username "$DOCKERHUB_USERNAME" --password "$DOCKERHUB_TOKEN"
- name: Download latest earthly
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.7.23/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
- name: Earthly version
run: earthly --version
- name: Run build
run: |
earthly --ci --allow-privileged --output +test --EARTHLY_RUBY_VERSION=$EARTHLY_RUBY_VERSION --EARTHLY_RAILS_VERSION=$EARTHLY_RAILS_VERSION --EARTHLY_DEVISE_VERSION=$EARTHLY_DEVISE_VERSION
if [ -f exit_code ]; then
exit $(cat exit_code)
else
echo "'exit_code' file missing, something failed in previous command"
exit 1
fi
10 changes: 5 additions & 5 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ VERSION 0.7

# This allows one to change the running Ruby version with:
#
# `earthly --allow-privileged +test --EARTHLY_RUBY_VERSION=3`
ARG --global EARTHLY_RUBY_VERSION=3.0.6
# `earthly --allow-privileged +test --EARTHLY_RUBY_VERSION=3.2`
ARG --global EARTHLY_RUBY_VERSION=3.1.6

# This allows one to change the running Rails version with:
#
# `earthly --allow-privileged +test --EARTHLY_RAILS_VERSION=7`
ARG --global EARTHLY_RAILS_VERSION=6.1.7.6
# `earthly --allow-privileged +test --EARTHLY_RAILS_VERSION=7.1`
ARG --global EARTHLY_RAILS_VERSION=7.0.8.7

# This allows one to change the running Rails version with:
#
# `earthly --allow-privileged +test --EARTHLY_DEVISE_VERSION=4.8.1`
ARG --global EARTHLY_DEVISE_VERSION=4.9.3
ARG --global EARTHLY_DEVISE_VERSION=4.9.4

FROM ruby:$EARTHLY_RUBY_VERSION
WORKDIR /gem
Expand Down
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ gem 'factory_girl_rails'
gem 'mocha', '~> 0.13.0'
# With Ruby >= 3.0
if ruby_version >= Gem::Version.new('3.0.0')
gem 'nokogiri', '~> 1.13.0'
if Gem::Version.new(rails_min_version) < Gem::Version.new('7.0.0')
gem 'nokogiri', '~> 1.13.0'
else
gem 'nokogiri', '~> 1.15.0'
end
else
gem 'nokogiri', '~> 1.12.0'
end
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

This is a fork of the [devise](https://github.com/plataformatec/devise) extension to allow your app to utilise [Google Authenticator](http://code.google.com/p/google-authenticator/) for Time-based One Time Passwords (TOTP).

The current version of this gem support Rails from version 4.2 (older versions
are requiring older version of Ruby, which is hard to maintain), until version
6.1.x.\
The current version of this gem support Rails from version 4.2, until version
7.0.x.\
For more details see the `.github/workflows/ci.yml` file.

Rails 7.1 and 7.2 need more work, see issue [#12](https://github.com/Pharmony/devise_gauth/issues/12).

## Installation

Add the gem to your Gemfile (don't forget devise too):
Expand Down
9 changes: 9 additions & 0 deletions app/helpers/devise_gauth_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

module DeviseGauthHelper
DEVISE_VERSION = Gem::Version.new(Gem::Specification.find_by_name('devise').version)

def devise_4_6_and_above?
Gem::Version.new('4.6.0') <= DEVISE_VERSION
end
end
4 changes: 4 additions & 0 deletions app/views/devise/displayqr/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
<% end %>

<%= form_for(resource, as: resource_name, url: [resource_name, :displayqr], html: { method: :put }) do |f| %>
<% if devise_4_6_and_above? %>
<%= render "devise/shared/error_messages", resource: resource %>
<% else %>
<%= devise_error_messages! %>
<% end %>
<h3><%= I18n.t('nice_request', scope: 'devise.registration') %></h3>
<p><%= f.label :gauth_enabled, I18n.t('qrstatus', scope: 'devise.registration') %><br />
<%= f.check_box :gauth_enabled %></p>
Expand Down
2 changes: 1 addition & 1 deletion devise_gauth.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
spec.license = 'MIT'

spec.required_ruby_version = if ENV.fetch('PUBLISHING_GEM', false)
['>= 2.4', '< 3.2']
['>= 2.4', '< 3.3']
else
">= #{ENV.fetch('EARTHLY_RUBY_VERSION')}"
end
Expand Down
2 changes: 0 additions & 2 deletions docker-compose-earthly.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

name: devise_gauth

services:
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

name: devise_gauth

services:
Expand Down
5 changes: 4 additions & 1 deletion test/orm/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
ActiveRecord::Migrator.migrate(migration_scripts_path)
elsif Rails.version >= '5.2' && Rails.version < '6.0'
ActiveRecord::MigrationContext.new(migration_scripts_path).migrate
else
elsif Rails.version >= '6.0' && Rails.version < '7.1'
ActiveRecord::MigrationContext.new(
migration_scripts_path,
ActiveRecord::Base.connection.schema_migration
).migrate
else
# Rails version 7.2 and newer
ActiveRecord::MigrationContext.new('db/migrate/').migrate
end
4 changes: 4 additions & 0 deletions test/rails_app/app/views/devise/displayqr/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
<% end %>

<%= form_for(resource, as: resource_name, url: [resource_name, :displayqr], html: { method: :put }) do |f| %>
<% if devise_4_6_and_above? %>
<%= render "devise/shared/error_messages", resource: resource %>
<% else %>
<%= devise_error_messages! %>
<% end %>
<h3><%= I18n.t('nice_request', scope: 'devise.registration') %></h3>
<p><%= f.label :gauth_enabled, I18n.t('qrstatus', scope: 'devise.registration') %><br />
<%= f.check_box :gauth_enabled %></p>
Expand Down
11 changes: 11 additions & 0 deletions test/rails_app/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,16 @@ class Application < Rails::Application
# was deprecated in Rails 6.0 and removed in Rails 6.1
config.active_record.sqlite3.represent_boolean_as_integer = true
end

if Rails.version >= '7.0' && Rails.version < '7.1'
# DEPRECATION WARNING: Using legacy connection handling is deprecated.
# Please set `legacy_connection_handling` to `false` in your application.
config.active_record.legacy_connection_handling = false
end

config.active_support.cache_format_version = 6.1 if Rails.version >= '6.1'
config.active_support.cache_format_version = 7.0 if Rails.version >= '7.0'
config.active_support.cache_format_version = 7.1 if Rails.version >= '7.1'
config.active_support.cache_format_version = 7.2 if Rails.version >= '7.2'
end
end
Empty file modified test/rails_app/script/rails
100644 → 100755
Empty file.