diff --git a/lib/active_record/associated_object/railtie.rb b/lib/active_record/associated_object/railtie.rb index e206488..76a05ae 100644 --- a/lib/active_record/associated_object/railtie.rb +++ b/lib/active_record/associated_object/railtie.rb @@ -6,14 +6,14 @@ class ActiveRecord::AssociatedObject::Railtie < Rails::Railtie end end - initializer "object_association.setup" do - ActiveSupport.on_load :active_job do - require "active_job/performs" - ActiveRecord::AssociatedObject.extend ActiveJob::Performs - rescue LoadError - # We haven't bundled active_job-performs, so we're continuing without it. - end + initializer "active_job.performs" do + require "active_job/performs" + ActiveRecord::AssociatedObject.extend ActiveJob::Performs if defined?(ActiveJob::Performs) + rescue LoadError + # We haven't bundled active_job-performs, so we're continuing without it. + end + initializer "object_association.setup" do ActiveSupport.on_load :active_record do require "active_record/associated_object/object_association" include ActiveRecord::AssociatedObject::ObjectAssociation diff --git a/test/test_helper.rb b/test/test_helper.rb index 0739c4d..a380f67 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -4,14 +4,16 @@ require "rails/railtie" require "kredis" -require "active_job" -require "global_id" require "debug" require "logger" require "active_record" require "active_record/associated_object" +require "global_id" +require "active_job" +require "active_job/performs" + require "minitest/autorun" # Simulate Rails app boot and run the railtie initializers manually.