Skip to content

Commit e9d9198

Browse files
authored
Fix Rails 7.1 deprecations (#31)
1 parent 618ff8e commit e9d9198

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Changelog
22

3-
## 0.10.0
3+
## 0.10.1
4+
- Fix Rails 7.1 deprecation warnings
45

6+
## 0.10.0
57
- Add support for Rails 7.1
68

79
## 0.9.0

lib/delayed/job_groups/compatibility.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
module Delayed
77
module JobGroups
88
module Compatibility
9+
ACTIVE_RECORD_VERSION = ::Gem::Version.new(::ActiveRecord::VERSION::STRING).release
10+
VERSION_7_1 = ::Gem::Version.new('7.1.0')
911

12+
def self.rails_7_1_or_greater?
13+
ACTIVE_RECORD_VERSION >= VERSION_7_1
14+
end
1015
end
1116
end
1217
end

lib/delayed/job_groups/job_group.rb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
# frozen_string_literal: true
22

33
require_relative 'yaml_loader'
4+
require_relative 'compatibility'
45

56
module Delayed
67
module JobGroups
78
class JobGroup < ActiveRecord::Base
89

910
self.table_name = "#{ActiveRecord::Base.table_name_prefix}delayed_job_groups"
1011

11-
serialize :on_completion_job, Delayed::JobGroups::YamlLoader
12-
serialize :on_completion_job_options, Hash
13-
serialize :on_cancellation_job, Delayed::JobGroups::YamlLoader
14-
serialize :on_cancellation_job_options, Hash
12+
if Compatibility.rails_7_1_or_greater?
13+
serialize :on_completion_job, coder: YAML, yaml: { unsafe_load: true }
14+
serialize :on_completion_job_options, coder: YAML, type: Hash
15+
serialize :on_cancellation_job, coder: YAML, yaml: { unsafe_load: true }
16+
serialize :on_cancellation_job_options, coder: YAML, type: Hash
17+
else
18+
serialize :on_completion_job, Delayed::JobGroups::YamlLoader
19+
serialize :on_completion_job_options, Hash
20+
serialize :on_cancellation_job, Delayed::JobGroups::YamlLoader
21+
serialize :on_cancellation_job_options, Hash
22+
end
23+
1524

1625
validates :queueing_complete, :blocked, :failure_cancels_group, inclusion: [true, false]
1726

lib/delayed/job_groups/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module Delayed
44
module JobGroups
5-
VERSION = '0.10.0'
5+
VERSION = '0.10.1'
66
end
77
end

lib/delayed/job_groups/yaml_loader.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
# This can be removed when we only support Rails 7.1+ because Rails 7.1 add a serialization
4+
# option for unsafe YAML loads
35
module Delayed
46
module JobGroups
57
module YamlLoader

0 commit comments

Comments
 (0)