From c696cffcf62e29a1214b9bcf6353d047e4fbfef2 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Wed, 11 Mar 2015 15:40:24 -0700 Subject: Fix naming collision --- activejob/test/cases/logging_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activejob/test') diff --git a/activejob/test/cases/logging_test.rb b/activejob/test/cases/logging_test.rb index 64aae00441..b18be553ec 100644 --- a/activejob/test/cases/logging_test.rb +++ b/activejob/test/cases/logging_test.rb @@ -6,7 +6,7 @@ require 'jobs/logging_job' require 'jobs/nested_job' require 'models/person' -class AdapterTest < ActiveSupport::TestCase +class LoggingTest < ActiveSupport::TestCase include ActiveSupport::LogSubscriber::TestHelper include ActiveSupport::Logger::Severity -- cgit v1.2.3 From fb26645c1ed9d3b74ec421839c9732706f74f5c0 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Wed, 11 Mar 2015 14:57:13 -0700 Subject: `ActiveJob::QueueAdapters::*` are no longer singletons --- activejob/test/cases/adapter_test.rb | 2 +- activejob/test/cases/queue_adapter_test.rb | 24 ++++++++++++++++++++++ activejob/test/cases/test_case_test.rb | 2 +- .../test/support/integration/test_case_helpers.rb | 4 ++-- 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 activejob/test/cases/queue_adapter_test.rb (limited to 'activejob/test') diff --git a/activejob/test/cases/adapter_test.rb b/activejob/test/cases/adapter_test.rb index f0c710f9ed..6d75ae9a7c 100644 --- a/activejob/test/cases/adapter_test.rb +++ b/activejob/test/cases/adapter_test.rb @@ -2,6 +2,6 @@ require 'helper' class AdapterTest < ActiveSupport::TestCase test "should load #{ENV['AJ_ADAPTER']} adapter" do - assert_equal "active_job/queue_adapters/#{ENV['AJ_ADAPTER']}_adapter".classify, ActiveJob::Base.queue_adapter.name + assert_equal "active_job/queue_adapters/#{ENV['AJ_ADAPTER']}_adapter".classify, ActiveJob::Base.queue_adapter.class.name end end diff --git a/activejob/test/cases/queue_adapter_test.rb b/activejob/test/cases/queue_adapter_test.rb new file mode 100644 index 0000000000..d801a0852c --- /dev/null +++ b/activejob/test/cases/queue_adapter_test.rb @@ -0,0 +1,24 @@ +require 'helper' + +class QueueAdapterTest < ActiveJob::TestCase + test 'should forbid nonsense arguments' do + assert_raises(ArgumentError) { ActiveJob::Base.queue_adapter = Mutex } + assert_raises(ArgumentError) { ActiveJob::Base.queue_adapter = Mutex.new } + end + + test 'should warn on passing an adapter class' do + klass = Class.new do + def self.name + 'fake' + end + + def enqueue(*) + end + + def enqueue_at(*) + end + end + + assert_deprecated { ActiveJob::Base.queue_adapter = klass } + end +end diff --git a/activejob/test/cases/test_case_test.rb b/activejob/test/cases/test_case_test.rb index 7d1702990e..bd23878b23 100644 --- a/activejob/test/cases/test_case_test.rb +++ b/activejob/test/cases/test_case_test.rb @@ -9,6 +9,6 @@ class ActiveJobTestCaseTest < ActiveJob::TestCase end def test_set_test_adapter - assert_equal ActiveJob::QueueAdapters::TestAdapter, self.queue_adapter + assert_kind_of ActiveJob::QueueAdapters::TestAdapter, self.queue_adapter end end diff --git a/activejob/test/support/integration/test_case_helpers.rb b/activejob/test/support/integration/test_case_helpers.rb index ee2f6aebea..fe075cf7c7 100644 --- a/activejob/test/support/integration/test_case_helpers.rb +++ b/activejob/test/support/integration/test_case_helpers.rb @@ -27,8 +27,8 @@ module TestCaseHelpers jobs_manager.clear_jobs end - def adapter_is?(adapter) - ActiveJob::Base.queue_adapter.name.split("::").last.gsub(/Adapter$/, '').underscore==adapter.to_s + def adapter_is?(adapter_class_symbol) + ActiveJob::Base.queue_adapter.class.name.split("::").last.gsub(/Adapter$/, '').underscore == adapter_class_symbol.to_s end def wait_for_jobs_to_finish_for(seconds=60) -- cgit v1.2.3