File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
app/jobs/outboxer_integration/message
spec/jobs/outboxer_integration/message Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,13 @@ def perform(args)
1616
1717 namespace , model , event = messageable_type . match ( MESSAGEABLE_TYPE_REGEX ) . captures
1818 job_class_name = "#{ namespace } ::#{ model } ::#{ event } Job"
19- job_class = job_class_name . constantize
20- job_class . perform_async ( { 'id' => args [ 'messageable_id' ] } )
19+
20+ begin
21+ job_class = job_class_name . constantize
22+ job_class . perform_async ( { 'id' => args [ 'messageable_id' ] } )
23+ rescue NameError
24+ # no-op
25+ end
2126 end
2227 end
2328 end
Original file line number Diff line number Diff line change @@ -35,6 +35,25 @@ module Message
3535 } . to raise_error ( StandardError , "Unexpected class name format: Wrong::Format::Test" )
3636 end
3737 end
38+
39+ context 'when job class does not exist' do
40+ let ( :args ) do
41+ {
42+ 'messageable_type' => 'Accountify::Models::Invoice::NonexistentEvent' ,
43+ 'messageable_id' => '123'
44+ }
45+ end
46+
47+ it 'completes gracefully without raising an error' do
48+ allow_any_instance_of ( String )
49+ . to receive ( :constantize )
50+ . and_raise ( NameError . new ( "uninitialized constant" ) )
51+
52+ expect {
53+ PublishJob . new . perform ( args )
54+ } . not_to raise_error
55+ end
56+ end
3857 end
3958 end
4059 end
You can’t perform that action at this time.
0 commit comments