diff options
Diffstat (limited to 'activejob/test')
-rw-r--r-- | activejob/test/cases/logging_test.rb | 7 | ||||
-rw-r--r-- | activejob/test/cases/test_helper_test.rb | 12 | ||||
-rw-r--r-- | activejob/test/jobs/overridden_logging_job.rb | 9 |
3 files changed, 27 insertions, 1 deletions
diff --git a/activejob/test/cases/logging_test.rb b/activejob/test/cases/logging_test.rb index 820e9112de..bf8a66432a 100644 --- a/activejob/test/cases/logging_test.rb +++ b/activejob/test/cases/logging_test.rb @@ -3,6 +3,7 @@ require "active_support/log_subscriber/test_helper" require 'active_support/core_ext/numeric/time' require 'jobs/hello_job' require 'jobs/logging_job' +require 'jobs/overridden_logging_job' require 'jobs/nested_job' require 'models/person' @@ -41,7 +42,6 @@ class LoggingTest < ActiveSupport::TestCase ActiveJob::Base.logger = logger end - def test_uses_active_job_as_tag HelloJob.perform_later "Cristian" assert_match(/\[ActiveJob\]/, @logger.messages) @@ -119,4 +119,9 @@ class LoggingTest < ActiveSupport::TestCase rescue NotImplementedError skip end + + def test_for_tagged_logger_support_is_consistent + set_logger ::Logger.new(nil) + OverriddenLoggingJob.perform_later "Dummy" + end end diff --git a/activejob/test/cases/test_helper_test.rb b/activejob/test/cases/test_helper_test.rb index f7ee763e8a..3d863f5e65 100644 --- a/activejob/test/cases/test_helper_test.rb +++ b/activejob/test/cases/test_helper_test.rb @@ -509,3 +509,15 @@ class PerformedJobsTest < ActiveJob::TestCase assert_equal 2, ActiveJob::Base.queue_adapter.performed_jobs.count end end + +class OverrideQueueAdapterTest < ActiveJob::TestCase + class CustomQueueAdapter < ActiveJob::QueueAdapters::TestAdapter; end + + def queue_adapter_for_test + CustomQueueAdapter.new + end + + def test_assert_job_has_custom_queue_adapter_set + assert_instance_of CustomQueueAdapter, HelloJob.queue_adapter + end +end diff --git a/activejob/test/jobs/overridden_logging_job.rb b/activejob/test/jobs/overridden_logging_job.rb new file mode 100644 index 0000000000..2b17a65142 --- /dev/null +++ b/activejob/test/jobs/overridden_logging_job.rb @@ -0,0 +1,9 @@ +class OverriddenLoggingJob < ActiveJob::Base + def perform(dummy) + logger.info "Dummy, here is it: #{dummy}" + end + + def logger + @logger ||= ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(nil)) + end +end |