Skip to content

Commit

Permalink
Merge pull request #216 from collectiveidea/bump-for-rails-7-1
Browse files Browse the repository at this point in the history
Add rails 7.1 to CI
  • Loading branch information
albus522 authored Sep 29, 2023
2 parents 97f26a3 + 054cd59 commit 6e8709f
Show file tree
Hide file tree
Showing 24 changed files with 147 additions and 41 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
- gemfiles/mysql2/7-0.gemfile
- gemfiles/postgresql/7-0.gemfile
- gemfiles/sqlite3/7-0.gemfile
- gemfiles/mysql2/7-1.gemfile
- gemfiles/postgresql/7-1.gemfile
- gemfiles/sqlite3/7-1.gemfile
include:
#
# The future
Expand Down
9 changes: 4 additions & 5 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ AllCops:
- vendor/**/*
NewCops: enable
SuggestExtensions: false
TargetRubyVersion: 2.0

#################
# [i] Overrides #
Expand Down Expand Up @@ -147,6 +148,9 @@ RSpec/NestedGroups:
RSpec/Capybara/FeatureMethods:
Enabled: false

RSpec/SpecFilePathFormat:
Enabled: false

###################
# Local overrides #
###################
Expand All @@ -165,8 +169,3 @@ Style/FormatStringToken:

Style/NumericPredicate:
Enabled: false

# We still allow really old versions of Ruby and Rails
# While I like the safe navigator, we don't want to use it here just yet
Style/SafeNavigation:
Enabled: false
4 changes: 2 additions & 2 deletions gemfiles/mysql2/3-0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ group :test do
gem "activerecord-mysql2-adapter"

gem "rspec", ">= 2.11"
gem "simplecov", ">= 0.20.0", require: false
gem "simplecov-lcov", ">= 0.8.0", require: false
gem "simplecov", ">= 0.17.0", require: false
gem "simplecov-lcov", "< 0.8.0", require: false

gem "activerecord", "~> 3.0.0"
end
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/mysql2/3-1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ gem "rake"
gem "mysql2", "~> 0.3.10"

gem "rspec", ">= 2.11"
gem "simplecov", ">= 0.20.0", require: false
gem "simplecov-lcov", ">= 0.8.0", require: false
gem "simplecov", ">= 0.17.0", require: false
gem "simplecov-lcov", "< 0.8.0", require: false

gem "activerecord", "~> 3.1.0"

Expand Down
4 changes: 2 additions & 2 deletions gemfiles/mysql2/4-0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ gem "rake"
gem "mysql2", "~> 0.3.10"

gem "rspec", ">= 2.11"
gem "simplecov", ">= 0.20.0", require: false
gem "simplecov-lcov", ">= 0.8.0", require: false
gem "simplecov", ">= 0.17.0", require: false
gem "simplecov-lcov", "< 0.8.0", require: false

gem "activerecord", "~> 4.0.0"

Expand Down
3 changes: 1 addition & 2 deletions gemfiles/mysql2/6-1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ gem "rake"

group :test do
platforms :jruby do
# Remove github when 61.0 releases
gem "activerecord-jdbcmysql-adapter", github: "jruby/activerecord-jdbc-adapter"
gem "activerecord-jdbcmysql-adapter"
end

platforms :ruby, :mswin, :mingw do
Expand Down
4 changes: 4 additions & 0 deletions gemfiles/mysql2/7-0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ source "https://rubygems.org"
gem "rake"

group :test do
platforms :jruby do
gem "activerecord-jdbcmysql-adapter"
end

platforms :ruby, :mswin, :mingw do
gem "mysql2", "~> 0.5"
end
Expand Down
24 changes: 24 additions & 0 deletions gemfiles/mysql2/7-1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

source "https://rubygems.org"

gem "rake"

group :test do
platforms :jruby do
# Remove github when 71.0 releases
gem "activerecord-jdbcmysql-adapter", github: "jruby/activerecord-jdbc-adapter"
end

platforms :ruby, :mswin, :mingw do
gem "mysql2", "~> 0.5"
end

gem "rspec", ">= 2.11"
gem "simplecov", ">= 0.20.0", require: false
gem "simplecov-lcov", ">= 0.8.0", require: false

gem "activerecord", "~> 7.1.0.rc1"
end

gemspec path: "../../"
4 changes: 2 additions & 2 deletions gemfiles/postgresql/3-0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ group :test do
gem "pg", "~> 0.18"

gem "rspec", ">= 2.11"
gem "simplecov", ">= 0.20.0", require: false
gem "simplecov-lcov", ">= 0.8.0", require: false
gem "simplecov", ">= 0.17.0", require: false
gem "simplecov-lcov", "< 0.8.0", require: false

gem "activerecord", "~> 3.0.0"
end
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/postgresql/3-1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ group :test do
gem "pg", "~> 0.18"

gem "rspec", ">= 2.11"
gem "simplecov", ">= 0.20.0", require: false
gem "simplecov-lcov", ">= 0.8.0", require: false
gem "simplecov", ">= 0.17.0", require: false
gem "simplecov-lcov", "< 0.8.0", require: false

gem "activerecord", "~> 3.1.0"
end
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/postgresql/4-0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ group :test do
gem "pg", "~> 0.18"

gem "rspec", ">= 2.11"
gem "simplecov", ">= 0.20.0", require: false
gem "simplecov-lcov", ">= 0.8.0", require: false
gem "simplecov", ">= 0.17.0", require: false
gem "simplecov-lcov", "< 0.8.0", require: false

gem "activerecord", "~> 4.0.0"
end
Expand Down
3 changes: 1 addition & 2 deletions gemfiles/postgresql/6-1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ gem "rake"

group :test do
platforms :jruby do
# Remove github when 61.0 releases
gem "activerecord-jdbcpostgresql-adapter", github: "jruby/activerecord-jdbc-adapter"
gem "activerecord-jdbcpostgresql-adapter"
end

platforms :ruby, :mswin, :mingw do
Expand Down
4 changes: 4 additions & 0 deletions gemfiles/postgresql/7-0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ source "https://rubygems.org"
gem "rake"

group :test do
platforms :jruby do
gem "activerecord-jdbcpostgresql-adapter"
end

platforms :ruby, :mswin, :mingw do
gem "pg", "~> 1.1"
end
Expand Down
24 changes: 24 additions & 0 deletions gemfiles/postgresql/7-1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

source "https://rubygems.org"

gem "rake"

group :test do
platforms :jruby do
# Remove github when 71.0 releases
gem "activerecord-jdbcmysql-adapter", github: "jruby/activerecord-jdbc-adapter"
end

platforms :ruby, :mswin, :mingw do
gem "pg", "~> 1.1"
end

gem "rspec", ">= 2.11"
gem "simplecov", ">= 0.20.0", require: false
gem "simplecov-lcov", ">= 0.8.0", require: false

gem "activerecord", "~> 7.1.0.rc1"
end

gemspec path: "../../"
4 changes: 2 additions & 2 deletions gemfiles/sqlite3/3-0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ group :test do
gem "sqlite3", "< 1.4"

gem "rspec", ">= 2.11"
gem "simplecov", ">= 0.20.0", require: false
gem "simplecov-lcov", ">= 0.8.0", require: false
gem "simplecov", ">= 0.17.0", require: false
gem "simplecov-lcov", "< 0.8.0", require: false

gem "activerecord", "~> 3.0.0"
end
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/sqlite3/3-1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ group :test do
gem "sqlite3", "< 1.4"

gem "rspec", ">= 2.11"
gem "simplecov", ">= 0.20.0", require: false
gem "simplecov-lcov", ">= 0.8.0", require: false
gem "simplecov", ">= 0.17.0", require: false
gem "simplecov-lcov", "< 0.8.0", require: false

gem "activerecord", "~> 3.1.0"
end
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/sqlite3/4-0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ group :test do
gem "sqlite3", "< 1.4"

gem "rspec", ">= 2.11"
gem "simplecov", ">= 0.20.0", require: false
gem "simplecov-lcov", ">= 0.8.0", require: false
gem "simplecov", ">= 0.17.0", require: false
gem "simplecov-lcov", "< 0.8.0", require: false

gem "activerecord", "~> 4.0.0"
end
Expand Down
3 changes: 1 addition & 2 deletions gemfiles/sqlite3/6-1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ gem "rake"

group :test do
platforms :jruby do
# Remove github when 61.0 releases
gem "activerecord-jdbcsqlite3-adapter", github: "jruby/activerecord-jdbc-adapter"
gem "activerecord-jdbcsqlite3-adapter"
end

platforms :ruby, :mswin, :mingw do
Expand Down
4 changes: 4 additions & 0 deletions gemfiles/sqlite3/7-0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ source "https://rubygems.org"
gem "rake"

group :test do
platforms :jruby do
gem "activerecord-jdbcsqlite3-adapter"
end

platforms :ruby, :mswin, :mingw do
gem "sqlite3", "~> 1.4"
end
Expand Down
24 changes: 24 additions & 0 deletions gemfiles/sqlite3/7-1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

source "https://rubygems.org"

gem "rake"

group :test do
platforms :jruby do
# Remove github when 71.0 releases
gem "activerecord-jdbcmysql-adapter", github: "jruby/activerecord-jdbc-adapter"
end

platforms :ruby, :mswin, :mingw do
gem "sqlite3", "~> 1.4"
end

gem "rspec", ">= 2.11"
gem "simplecov", ">= 0.20.0", require: false
gem "simplecov-lcov", ">= 0.8.0", require: false

gem "activerecord", "~> 7.1.0.rc1"
end

gemspec path: "../../"
10 changes: 9 additions & 1 deletion lib/delayed/backend/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,21 @@ def self.reserve_with_scope_using_optimized_mssql(ready_scope, worker, now)
def self.db_time_now
if Time.zone
Time.zone.now
elsif ::ActiveRecord::Base.default_timezone == :utc
elsif default_timezone == :utc
Time.now.utc
else
Time.now # rubocop:disable Rails/TimeZone
end
end

def self.default_timezone
if ::ActiveRecord.respond_to?(:default_timezone)
::ActiveRecord.default_timezone
else
::ActiveRecord::Base.default_timezone
end
end

def reload(*args)
reset
super
Expand Down
9 changes: 8 additions & 1 deletion lib/generators/delayed_job/next_migration_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ module NextMigrationVersion
# since ActiveRecord 3.0
def next_migration_number(dirname)
next_migration_number = current_migration_number(dirname) + 1
if ActiveRecord::Base.timestamped_migrations
timestamped_migrations =
if ActiveRecord.respond_to?(:timestamped_migrations)
ActiveRecord.timestamped_migrations
else
ActiveRecord::Base.timestamped_migrations
end

if timestamped_migrations
[Time.now.utc.strftime("%Y%m%d%H%M%S"), format("%.14d", next_migration_number)].max
else
format("%.3d", next_migration_number)
Expand Down
22 changes: 15 additions & 7 deletions spec/delayed/backend/active_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,17 @@
end

context "db_time_now" do
def use_default_timezone(timezone)
if ActiveRecord.respond_to?(:default_timezone=)
ActiveRecord.default_timezone = timezone
else
ActiveRecord::Base.default_timezone = timezone
end
end

after do
Time.zone = nil
ActiveRecord::Base.default_timezone = :local
use_default_timezone(:local)
end

it "returns time in current time zone if set" do
Expand All @@ -88,13 +96,13 @@

it "returns UTC time if that is the AR default" do
Time.zone = nil
ActiveRecord::Base.default_timezone = :utc
use_default_timezone(:utc)
expect(Delayed::Backend::ActiveRecord::Job.db_time_now.zone).to eq "UTC"
end

it "returns local time if that is the AR default" do
Time.zone = "Arizona"
ActiveRecord::Base.default_timezone = :local
use_default_timezone(:local)
expect(Delayed::Backend::ActiveRecord::Job.db_time_now.zone).to eq("MST")
end
end
Expand All @@ -115,7 +123,7 @@
end
end

if ::ActiveRecord::VERSION::MAJOR < 4 || defined?(::ActiveRecord::MassAssignmentSecurity)
if ActiveRecord::VERSION::MAJOR < 4 || defined?(ActiveRecord::MassAssignmentSecurity)
context "ActiveRecord::Base.send(:attr_accessible, nil)" do
before do
Delayed::Backend::ActiveRecord::Job.send(:attr_accessible, nil)
Expand All @@ -137,19 +145,19 @@

context "ActiveRecord::Base.table_name_prefix" do
it "when prefix is not set, use 'delayed_jobs' as table name" do
::ActiveRecord::Base.table_name_prefix = nil
ActiveRecord::Base.table_name_prefix = nil
Delayed::Backend::ActiveRecord::Job.set_delayed_job_table_name

expect(Delayed::Backend::ActiveRecord::Job.table_name).to eq "delayed_jobs"
end

it "when prefix is set, prepend it before default table name" do
::ActiveRecord::Base.table_name_prefix = "custom_"
ActiveRecord::Base.table_name_prefix = "custom_"
Delayed::Backend::ActiveRecord::Job.set_delayed_job_table_name

expect(Delayed::Backend::ActiveRecord::Job.table_name).to eq "custom_delayed_jobs"

::ActiveRecord::Base.table_name_prefix = nil
ActiveRecord::Base.table_name_prefix = nil
Delayed::Backend::ActiveRecord::Job.set_delayed_job_table_name
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
Delayed::Worker.logger = Logger.new("/tmp/dj.log")
ENV["RAILS_ENV"] = "test"

db_adapter = ENV["ADAPTER"]
gemfile = ENV["BUNDLE_GEMFILE"]
db_adapter = ENV.fetch("ADAPTER", nil)
gemfile = ENV.fetch("BUNDLE_GEMFILE", nil)
db_adapter ||= gemfile && gemfile[%r{gemfiles/(.*?)/}] && $1 # rubocop:disable Style/PerlBackrefs
db_adapter ||= "sqlite3"

config = YAML.load(File.read("spec/database.yml"))
config = YAML.load_file("spec/database.yml")
ActiveRecord::Base.establish_connection config[db_adapter]
ActiveRecord::Base.logger = Delayed::Worker.logger
ActiveRecord::Migration.verbose = false
Expand Down

0 comments on commit 6e8709f

Please sign in to comment.