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

Fix error ActiveJob passed class with permitted? #48566

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion activejob/lib/active_job/arguments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def serialize_argument(argument)
result = serialize_hash(argument)
result[aj_hash_key] = symbol_keys
result
when -> (arg) { arg.respond_to?(:permitted?) }
when -> (arg) { arg.respond_to?(:permitted?) && arg.respond_to?(:to_h) }
serialize_indifferent_hash(argument.to_h)
else
if BigDecimal === argument && !ActiveJob.use_big_decimal_serializer
Expand Down
10 changes: 10 additions & 0 deletions activejob/test/cases/argument_serialization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ class ClassArgument; end

class ClassArgument; end

class MyClassWithPermitted
def self.permitted?
end
end

setup do
@person = Person.find("5")
end
Expand Down Expand Up @@ -112,6 +117,11 @@ class ClassArgument; end
)
end

# Regression test to #48561
test "serialize a class with permitted? defined" do
assert_arguments_unchanged MyClassWithPermitted
end

test "serialize a hash" do
symbol_key = { a: 1 }
string_key = { "a" => 1 }
Expand Down