diff options
author | Xavier Noria <fxn@hashref.com> | 2016-08-06 18:41:18 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-08-06 18:41:18 +0200 |
commit | bde6547bb6a8ddf18fb687bf20893d3dc87e0358 (patch) | |
tree | 549bb6e0b876050f688453aaae9d3e03d65e0a34 /activejob | |
parent | 93c9534c9871d4adad4bc33b5edc355672b59c61 (diff) | |
download | rails-bde6547bb6a8ddf18fb687bf20893d3dc87e0358.tar.gz rails-bde6547bb6a8ddf18fb687bf20893d3dc87e0358.tar.bz2 rails-bde6547bb6a8ddf18fb687bf20893d3dc87e0358.zip |
applies new string literal convention in activejob/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
Diffstat (limited to 'activejob')
47 files changed, 279 insertions, 279 deletions
diff --git a/activejob/test/adapters/backburner.rb b/activejob/test/adapters/backburner.rb index 65d05f850b..0bd4aad5d3 100644 --- a/activejob/test/adapters/backburner.rb +++ b/activejob/test/adapters/backburner.rb @@ -1,3 +1,3 @@ -require 'support/backburner/inline' +require "support/backburner/inline" ActiveJob::Base.queue_adapter = :backburner
\ No newline at end of file diff --git a/activejob/test/adapters/qu.rb b/activejob/test/adapters/qu.rb index 7728c843b4..b89c504091 100644 --- a/activejob/test/adapters/qu.rb +++ b/activejob/test/adapters/qu.rb @@ -1,3 +1,3 @@ -require 'qu-immediate' +require "qu-immediate" ActiveJob::Base.queue_adapter = :qu diff --git a/activejob/test/adapters/que.rb b/activejob/test/adapters/que.rb index e6abc57457..0c49274a4e 100644 --- a/activejob/test/adapters/que.rb +++ b/activejob/test/adapters/que.rb @@ -1,4 +1,4 @@ -require 'support/que/inline' +require "support/que/inline" ActiveJob::Base.queue_adapter = :que Que.mode = :sync diff --git a/activejob/test/adapters/queue_classic.rb b/activejob/test/adapters/queue_classic.rb index ad5ced3cc2..e301a7ca96 100644 --- a/activejob/test/adapters/queue_classic.rb +++ b/activejob/test/adapters/queue_classic.rb @@ -1,2 +1,2 @@ -require 'support/queue_classic/inline' +require "support/queue_classic/inline" ActiveJob::Base.queue_adapter = :queue_classic diff --git a/activejob/test/adapters/sidekiq.rb b/activejob/test/adapters/sidekiq.rb index cd9d2034de..8036331ef1 100644 --- a/activejob/test/adapters/sidekiq.rb +++ b/activejob/test/adapters/sidekiq.rb @@ -1,2 +1,2 @@ -require 'sidekiq/testing/inline' +require "sidekiq/testing/inline" ActiveJob::Base.queue_adapter = :sidekiq diff --git a/activejob/test/adapters/sneakers.rb b/activejob/test/adapters/sneakers.rb index 204166a700..159c0d1906 100644 --- a/activejob/test/adapters/sneakers.rb +++ b/activejob/test/adapters/sneakers.rb @@ -1,2 +1,2 @@ -require 'support/sneakers/inline' +require "support/sneakers/inline" ActiveJob::Base.queue_adapter = :sneakers diff --git a/activejob/test/adapters/sucker_punch.rb b/activejob/test/adapters/sucker_punch.rb index d2d1712946..5661b6ee92 100644 --- a/activejob/test/adapters/sucker_punch.rb +++ b/activejob/test/adapters/sucker_punch.rb @@ -1,2 +1,2 @@ -require 'sucker_punch/testing/inline' +require "sucker_punch/testing/inline" ActiveJob::Base.queue_adapter = :sucker_punch diff --git a/activejob/test/cases/adapter_test.rb b/activejob/test/cases/adapter_test.rb index 6d75ae9a7c..caf5d44a5e 100644 --- a/activejob/test/cases/adapter_test.rb +++ b/activejob/test/cases/adapter_test.rb @@ -1,4 +1,4 @@ -require 'helper' +require "helper" class AdapterTest < ActiveSupport::TestCase test "should load #{ENV['AJ_ADAPTER']} adapter" do diff --git a/activejob/test/cases/argument_serialization_test.rb b/activejob/test/cases/argument_serialization_test.rb index 75b06ebde4..af3d4f2a8e 100644 --- a/activejob/test/cases/argument_serialization_test.rb +++ b/activejob/test/cases/argument_serialization_test.rb @@ -1,25 +1,25 @@ -require 'helper' -require 'active_job/arguments' -require 'models/person' -require 'active_support/core_ext/hash/indifferent_access' -require 'jobs/kwargs_job' +require "helper" +require "active_job/arguments" +require "models/person" +require "active_support/core_ext/hash/indifferent_access" +require "jobs/kwargs_job" class ArgumentSerializationTest < ActiveSupport::TestCase setup do - @person = Person.find('5') + @person = Person.find("5") end [ nil, 1, 1.0, 1_000_000_000_000_000_000_000, - 'a', true, false, BigDecimal.new(5), - [ 1, 'a' ], - { 'a' => 1 } + "a", true, false, BigDecimal.new(5), + [ 1, "a" ], + { "a" => 1 } ].each do |arg| test "serializes #{arg.class} - #{arg} verbatim" do assert_arguments_unchanged arg end end - [ :a, Object.new, self, Person.find('5').to_gid ].each do |arg| + [ :a, Object.new, self, Person.find("5").to_gid ].each do |arg| test "does not serialize #{arg.class}" do assert_raises ActiveJob::SerializationError do ActiveJob::Arguments.serialize [ arg ] @@ -31,22 +31,22 @@ class ArgumentSerializationTest < ActiveSupport::TestCase end end - test 'should convert records to Global IDs' do + test "should convert records to Global IDs" do assert_arguments_roundtrip [@person] end - test 'should dive deep into arrays and hashes' do + test "should dive deep into arrays and hashes" do assert_arguments_roundtrip [3, [@person]] - assert_arguments_roundtrip [{ 'a' => @person }] + assert_arguments_roundtrip [{ "a" => @person }] end - test 'should maintain string and symbol keys' do + test "should maintain string and symbol keys" do assert_arguments_roundtrip([a: 1, "b" => 2]) end - test 'should maintain hash with indifferent access' do + test "should maintain hash with indifferent access" do symbol_key = { a: 1 } - string_key = { 'a' => 1 } + string_key = { "a" => 1 } indifferent_access = { a: 1 }.with_indifferent_access assert_not_instance_of ActiveSupport::HashWithIndifferentAccess, perform_round_trip([symbol_key]).first @@ -54,7 +54,7 @@ class ArgumentSerializationTest < ActiveSupport::TestCase assert_instance_of ActiveSupport::HashWithIndifferentAccess, perform_round_trip([indifferent_access]).first end - test 'should disallow non-string/symbol hash keys' do + test "should disallow non-string/symbol hash keys" do assert_raises ActiveJob::SerializationError do ActiveJob::Arguments.serialize [ { 1 => 2 } ] end @@ -64,16 +64,16 @@ class ArgumentSerializationTest < ActiveSupport::TestCase end end - test 'should not allow reserved hash keys' do - ['_aj_globalid', :_aj_globalid, '_aj_symbol_keys', :_aj_symbol_keys, - '_aj_hash_with_indifferent_access', :_aj_hash_with_indifferent_access].each do |key| + test "should not allow reserved hash keys" do + ["_aj_globalid", :_aj_globalid, "_aj_symbol_keys", :_aj_symbol_keys, + "_aj_hash_with_indifferent_access", :_aj_hash_with_indifferent_access].each do |key| assert_raises ActiveJob::SerializationError do ActiveJob::Arguments.serialize [key => 1] end end end - test 'should not allow non-primitive objects' do + test "should not allow non-primitive objects" do assert_raises ActiveJob::SerializationError do ActiveJob::Arguments.serialize [Object.new] end @@ -83,17 +83,17 @@ class ArgumentSerializationTest < ActiveSupport::TestCase end end - test 'allows for keyword arguments' do + test "allows for keyword arguments" do KwargsJob.perform_later(argument: 2) assert_equal "Job with argument: 2", JobBuffer.last_value end - test 'raises a friendly SerializationError for records without ids' do + test "raises a friendly SerializationError for records without ids" do err = assert_raises ActiveJob::SerializationError do ActiveJob::Arguments.serialize [Person.new(nil)] end - assert_match 'Unable to serialize Person without an id.', err.message + assert_match "Unable to serialize Person without an id.", err.message end private diff --git a/activejob/test/cases/callbacks_test.rb b/activejob/test/cases/callbacks_test.rb index 9af2380767..8d1c9c3058 100644 --- a/activejob/test/cases/callbacks_test.rb +++ b/activejob/test/cases/callbacks_test.rb @@ -1,10 +1,10 @@ -require 'helper' -require 'jobs/callback_job' +require "helper" +require "jobs/callback_job" -require 'active_support/core_ext/object/inclusion' +require "active_support/core_ext/object/inclusion" class CallbacksTest < ActiveSupport::TestCase - test 'perform callbacks' do + test "perform callbacks" do performed_callback_job = CallbackJob.new("A-JOB-ID") performed_callback_job.perform_now assert "CallbackJob ran before_perform".in? performed_callback_job.history @@ -13,7 +13,7 @@ class CallbacksTest < ActiveSupport::TestCase assert "CallbackJob ran around_perform_stop".in? performed_callback_job.history end - test 'enqueue callbacks' do + test "enqueue callbacks" do enqueued_callback_job = CallbackJob.perform_later assert "CallbackJob ran before_enqueue".in? enqueued_callback_job.history assert "CallbackJob ran after_enqueue".in? enqueued_callback_job.history diff --git a/activejob/test/cases/exceptions_test.rb b/activejob/test/cases/exceptions_test.rb index 58d87a339a..004e9f4305 100644 --- a/activejob/test/cases/exceptions_test.rb +++ b/activejob/test/cases/exceptions_test.rb @@ -1,5 +1,5 @@ -require 'helper' -require 'jobs/retry_job' +require "helper" +require "jobs/retry_job" class ExceptionsTest < ActiveJob::TestCase setup do @@ -9,7 +9,7 @@ class ExceptionsTest < ActiveJob::TestCase test "successfully retry job throwing exception against defaults" do perform_enqueued_jobs do - RetryJob.perform_later 'DefaultsError', 5 + RetryJob.perform_later "DefaultsError", 5 assert_equal [ "Raised DefaultsError for the 1st time", @@ -22,7 +22,7 @@ class ExceptionsTest < ActiveJob::TestCase test "successfully retry job throwing exception against higher limit" do perform_enqueued_jobs do - RetryJob.perform_later 'ShortWaitTenAttemptsError', 9 + RetryJob.perform_later "ShortWaitTenAttemptsError", 9 assert_equal 9, JobBuffer.values.count end end @@ -30,7 +30,7 @@ class ExceptionsTest < ActiveJob::TestCase test "failed retry job when exception kept occurring against defaults" do perform_enqueued_jobs do begin - RetryJob.perform_later 'DefaultsError', 6 + RetryJob.perform_later "DefaultsError", 6 assert_equal "Raised DefaultsError for the 5th time", JobBuffer.last_value rescue DefaultsError pass @@ -41,7 +41,7 @@ class ExceptionsTest < ActiveJob::TestCase test "failed retry job when exception kept occurring against higher limit" do perform_enqueued_jobs do begin - RetryJob.perform_later 'ShortWaitTenAttemptsError', 11 + RetryJob.perform_later "ShortWaitTenAttemptsError", 11 assert_equal "Raised ShortWaitTenAttemptsError for the 10th time", JobBuffer.last_value rescue ShortWaitTenAttemptsError pass @@ -51,14 +51,14 @@ class ExceptionsTest < ActiveJob::TestCase test "discard job" do perform_enqueued_jobs do - RetryJob.perform_later 'DiscardableError', 2 + RetryJob.perform_later "DiscardableError", 2 assert_equal "Raised DiscardableError for the 1st time", JobBuffer.last_value end end test "custom handling of job that exceeds retry attempts" do perform_enqueued_jobs do - RetryJob.perform_later 'CustomCatchError', 6 + RetryJob.perform_later "CustomCatchError", 6 assert_equal "Dealt with a job that failed to retry in a custom way", JobBuffer.last_value end end @@ -68,7 +68,7 @@ class ExceptionsTest < ActiveJob::TestCase perform_enqueued_jobs do assert_performed_with at: (Time.now + 3600.seconds).to_i do - RetryJob.perform_later 'LongWaitError', 5 + RetryJob.perform_later "LongWaitError", 5 end end end @@ -81,7 +81,7 @@ class ExceptionsTest < ActiveJob::TestCase assert_performed_with at: (Time.now + 18.seconds).to_i do assert_performed_with at: (Time.now + 83.seconds).to_i do assert_performed_with at: (Time.now + 258.seconds).to_i do - RetryJob.perform_later 'ExponentialWaitTenAttemptsError', 5 + RetryJob.perform_later "ExponentialWaitTenAttemptsError", 5 end end end @@ -97,7 +97,7 @@ class ExceptionsTest < ActiveJob::TestCase assert_performed_with at: (Time.now + 4.seconds).to_i do assert_performed_with at: (Time.now + 6.seconds).to_i do assert_performed_with at: (Time.now + 8.seconds).to_i do - RetryJob.perform_later 'CustomWaitTenAttemptsError', 5 + RetryJob.perform_later "CustomWaitTenAttemptsError", 5 end end end diff --git a/activejob/test/cases/job_serialization_test.rb b/activejob/test/cases/job_serialization_test.rb index fa94209889..3f2e300dfa 100644 --- a/activejob/test/cases/job_serialization_test.rb +++ b/activejob/test/cases/job_serialization_test.rb @@ -1,8 +1,8 @@ -require 'helper' -require 'jobs/gid_job' -require 'jobs/hello_job' -require 'models/person' -require 'json' +require "helper" +require "jobs/gid_job" +require "jobs/hello_job" +require "models/person" +require "json" class JobSerializationTest < ActiveSupport::TestCase setup do @@ -10,16 +10,16 @@ class JobSerializationTest < ActiveSupport::TestCase @person = Person.find(5) end - test 'serialize job with gid' do + test "serialize job with gid" do GidJob.perform_later @person assert_equal "Person with ID: 5", JobBuffer.last_value end - test 'serialize includes current locale' do - assert_equal 'en', HelloJob.new.serialize['locale'] + test "serialize includes current locale" do + assert_equal "en", HelloJob.new.serialize["locale"] end - test 'serialize and deserialize are symmetric' do + test "serialize and deserialize are symmetric" do # Round trip a job in memory only h1 = HelloJob.new h1.deserialize(h1.serialize) @@ -33,15 +33,15 @@ class JobSerializationTest < ActiveSupport::TestCase assert_equal h1.serialize, h2.serialize end - test 'deserialize sets locale' do + test "deserialize sets locale" do job = HelloJob.new - job.deserialize 'locale' => 'es' - assert_equal 'es', job.locale + job.deserialize "locale" => "es" + assert_equal "es", job.locale end - test 'deserialize sets default locale' do + test "deserialize sets default locale" do job = HelloJob.new job.deserialize({}) - assert_equal 'en', job.locale + assert_equal "en", job.locale end end diff --git a/activejob/test/cases/logging_test.rb b/activejob/test/cases/logging_test.rb index bf8a66432a..954974b2a5 100644 --- a/activejob/test/cases/logging_test.rb +++ b/activejob/test/cases/logging_test.rb @@ -1,11 +1,11 @@ -require 'helper' +require "helper" 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' +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" class LoggingTest < ActiveSupport::TestCase include ActiveSupport::LogSubscriber::TestHelper diff --git a/activejob/test/cases/queue_adapter_test.rb b/activejob/test/cases/queue_adapter_test.rb index fb3fdc392f..dc862450aa 100644 --- a/activejob/test/cases/queue_adapter_test.rb +++ b/activejob/test/cases/queue_adapter_test.rb @@ -1,4 +1,4 @@ -require 'helper' +require "helper" module ActiveJob module QueueAdapters @@ -15,15 +15,15 @@ module ActiveJob end class QueueAdapterTest < ActiveJob::TestCase - test 'should forbid nonsense arguments' do + 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 + test "should warn on passing an adapter class" do klass = Class.new do def self.name - 'fake' + "fake" end def enqueue(*); end @@ -33,7 +33,7 @@ class QueueAdapterTest < ActiveJob::TestCase assert_deprecated { ActiveJob::Base.queue_adapter = klass } end - test 'should allow overriding the queue_adapter at the child class level without affecting the parent or its sibling' do + test "should allow overriding the queue_adapter at the child class level without affecting the parent or its sibling" do base_queue_adapter = ActiveJob::Base.queue_adapter child_job_one = Class.new(ActiveJob::Base) diff --git a/activejob/test/cases/queue_naming_test.rb b/activejob/test/cases/queue_naming_test.rb index 898016a704..7777e557c9 100644 --- a/activejob/test/cases/queue_naming_test.rb +++ b/activejob/test/cases/queue_naming_test.rb @@ -1,14 +1,14 @@ -require 'helper' -require 'jobs/hello_job' -require 'jobs/logging_job' -require 'jobs/nested_job' +require "helper" +require "jobs/hello_job" +require "jobs/logging_job" +require "jobs/nested_job" class QueueNamingTest < ActiveSupport::TestCase - test 'name derived from base' do + test "name derived from base" do assert_equal "default", HelloJob.queue_name end - test 'uses given queue name job' do + test "uses given queue name job" do original_queue_name = HelloJob.queue_name begin @@ -19,7 +19,7 @@ class QueueNamingTest < ActiveSupport::TestCase end end - test 'allows a blank queue name' do + test "allows a blank queue name" do original_queue_name = HelloJob.queue_name begin @@ -30,7 +30,7 @@ class QueueNamingTest < ActiveSupport::TestCase end end - test 'does not use a nil queue name' do + test "does not use a nil queue name" do original_queue_name = HelloJob.queue_name begin @@ -41,7 +41,7 @@ class QueueNamingTest < ActiveSupport::TestCase end end - test 'evals block given to queue_as to determine queue' do + test "evals block given to queue_as to determine queue" do original_queue_name = HelloJob.queue_name begin @@ -52,42 +52,42 @@ class QueueNamingTest < ActiveSupport::TestCase end end - test 'can use arguments to determine queue_name in queue_as block' do + test "can use arguments to determine queue_name in queue_as block" do original_queue_name = HelloJob.queue_name begin - HelloJob.queue_as { self.arguments.first=='1' ? :one : :two } - assert_equal "one", HelloJob.new('1').queue_name - assert_equal "two", HelloJob.new('3').queue_name + HelloJob.queue_as { self.arguments.first=="1" ? :one : :two } + assert_equal "one", HelloJob.new("1").queue_name + assert_equal "two", HelloJob.new("3").queue_name ensure HelloJob.queue_name = original_queue_name end end - test 'queue_name_prefix prepended to the queue name with default delimiter' do + test "queue_name_prefix prepended to the queue name with default delimiter" do original_queue_name_prefix = ActiveJob::Base.queue_name_prefix original_queue_name = HelloJob.queue_name begin - ActiveJob::Base.queue_name_prefix = 'aj' + ActiveJob::Base.queue_name_prefix = "aj" HelloJob.queue_as :low - assert_equal 'aj_low', HelloJob.queue_name + assert_equal "aj_low", HelloJob.queue_name ensure ActiveJob::Base.queue_name_prefix = original_queue_name_prefix HelloJob.queue_name = original_queue_name end end - test 'queue_name_prefix prepended to the queue name with custom delimiter' do + test "queue_name_prefix prepended to the queue name with custom delimiter" do original_queue_name_prefix = ActiveJob::Base.queue_name_prefix original_queue_name_delimiter = ActiveJob::Base.queue_name_delimiter original_queue_name = HelloJob.queue_name begin - ActiveJob::Base.queue_name_delimiter = '.' - ActiveJob::Base.queue_name_prefix = 'aj' + ActiveJob::Base.queue_name_delimiter = "." + ActiveJob::Base.queue_name_prefix = "aj" HelloJob.queue_as :low - assert_equal 'aj.low', HelloJob.queue_name + assert_equal "aj.low", HelloJob.queue_name ensure ActiveJob::Base.queue_name_prefix = original_queue_name_prefix ActiveJob::Base.queue_name_delimiter = original_queue_name_delimiter @@ -95,7 +95,7 @@ class QueueNamingTest < ActiveSupport::TestCase end end - test 'uses queue passed to #set' do + test "uses queue passed to #set" do job = HelloJob.set(queue: :some_queue).perform_later assert_equal "some_queue", job.queue_name end diff --git a/activejob/test/cases/queue_priority_test.rb b/activejob/test/cases/queue_priority_test.rb index ca17b51dad..ab4a1bdf7b 100644 --- a/activejob/test/cases/queue_priority_test.rb +++ b/activejob/test/cases/queue_priority_test.rb @@ -1,12 +1,12 @@ -require 'helper' -require 'jobs/hello_job' +require "helper" +require "jobs/hello_job" class QueuePriorityTest < ActiveSupport::TestCase - test 'priority unset by default' do + test "priority unset by default" do assert_equal nil, HelloJob.priority end - test 'uses given priority' do + test "uses given priority" do original_priority = HelloJob.priority begin @@ -17,7 +17,7 @@ class QueuePriorityTest < ActiveSupport::TestCase end end - test 'evals block given to priority to determine priority' do + test "evals block given to priority to determine priority" do original_priority = HelloJob.priority begin @@ -28,19 +28,19 @@ class QueuePriorityTest < ActiveSupport::TestCase end end - test 'can use arguments to determine priority in priority block' do + test "can use arguments to determine priority in priority block" do original_priority = HelloJob.priority begin - HelloJob.queue_with_priority { self.arguments.first=='1' ? 99 : 11 } - assert_equal 99, HelloJob.new('1').priority - assert_equal 11, HelloJob.new('3').priority + HelloJob.queue_with_priority { self.arguments.first=="1" ? 99 : 11 } + assert_equal 99, HelloJob.new("1").priority + assert_equal 11, HelloJob.new("3").priority ensure HelloJob.priority = original_priority end end - test 'uses priority passed to #set' do + test "uses priority passed to #set" do job = HelloJob.set(priority: 123).perform_later assert_equal 123, job.priority end diff --git a/activejob/test/cases/queuing_test.rb b/activejob/test/cases/queuing_test.rb index 0eeabbf693..9690e0cc79 100644 --- a/activejob/test/cases/queuing_test.rb +++ b/activejob/test/cases/queuing_test.rb @@ -1,6 +1,6 @@ -require 'helper' -require 'jobs/hello_job' -require 'active_support/core_ext/numeric/time' +require "helper" +require "jobs/hello_job" +require "active_support/core_ext/numeric/time" class QueuingTest < ActiveSupport::TestCase @@ -8,17 +8,17 @@ class QueuingTest < ActiveSupport::TestCase JobBuffer.clear end - test 'run queued job' do + test "run queued job" do HelloJob.perform_later assert_equal "David says hello", JobBuffer.last_value end - test 'run queued job with arguments' do + test "run queued job with arguments" do HelloJob.perform_later "Jamie" assert_equal "Jamie says hello", JobBuffer.last_value end - test 'run queued job later' do + test "run queued job later" do begin result = HelloJob.set(wait_until: 1.second.ago).perform_later "Jamie" assert result @@ -27,13 +27,13 @@ class QueuingTest < ActiveSupport::TestCase end end - test 'job returned by enqueue has the arguments available' do + test "job returned by enqueue has the arguments available" do job = HelloJob.perform_later "Jamie" assert_equal [ "Jamie" ], job.arguments end - test 'job returned by perform_at has the timestamp available' do + test "job returned by perform_at has the timestamp available" do begin job = HelloJob.set(wait_until: Time.utc(2014, 1, 1)).perform_later assert_equal Time.utc(2014, 1, 1).to_f, job.scheduled_at diff --git a/activejob/test/cases/rescue_test.rb b/activejob/test/cases/rescue_test.rb index 58c9ca8992..afb1b48831 100644 --- a/activejob/test/cases/rescue_test.rb +++ b/activejob/test/cases/rescue_test.rb @@ -1,34 +1,34 @@ -require 'helper' -require 'jobs/rescue_job' -require 'models/person' +require "helper" +require "jobs/rescue_job" +require "models/person" class RescueTest < ActiveSupport::TestCase setup do JobBuffer.clear end - test 'rescue perform exception with retry' do + test "rescue perform exception with retry" do job = RescueJob.new("david") job.perform_now assert_equal [ "rescued from ArgumentError", "performed beautifully" ], JobBuffer.values end - test 'let through unhandled perform exception' do + test "let through unhandled perform exception" do job = RescueJob.new("other") assert_raises(RescueJob::OtherError) do job.perform_now end end - test 'rescue from deserialization errors' do + test "rescue from deserialization errors" do RescueJob.perform_later Person.new(404) - assert_includes JobBuffer.values, 'rescued from DeserializationError' - assert_includes JobBuffer.values, 'DeserializationError original exception was Person::RecordNotFound' - assert_not_includes JobBuffer.values, 'performed beautifully' + assert_includes JobBuffer.values, "rescued from DeserializationError" + assert_includes JobBuffer.values, "DeserializationError original exception was Person::RecordNotFound" + assert_not_includes JobBuffer.values, "performed beautifully" end test "should not wrap DeserializationError in DeserializationError" do RescueJob.perform_later [Person.new(404)] - assert_includes JobBuffer.values, 'DeserializationError original exception was Person::RecordNotFound' + assert_includes JobBuffer.values, "DeserializationError original exception was Person::RecordNotFound" end end diff --git a/activejob/test/cases/test_case_test.rb b/activejob/test/cases/test_case_test.rb index 616454a4b6..23fffd4235 100644 --- a/activejob/test/cases/test_case_test.rb +++ b/activejob/test/cases/test_case_test.rb @@ -1,7 +1,7 @@ -require 'helper' -require 'jobs/hello_job' -require 'jobs/logging_job' -require 'jobs/nested_job' +require "helper" +require "jobs/hello_job" +require "jobs/logging_job" +require "jobs/nested_job" class ActiveJobTestCaseTest < ActiveJob::TestCase # this tests that this job class doesn't get its adapter set. @@ -9,7 +9,7 @@ class ActiveJobTestCaseTest < ActiveJob::TestCase # the `class_attribute` inheritance class TestClassAttributeInheritanceJob < ActiveJob::Base def self.queue_adapter=(*) - raise 'Attempting to break `class_attribute` inheritance, bad!' + raise "Attempting to break `class_attribute` inheritance, bad!" end end diff --git a/activejob/test/cases/test_helper_test.rb b/activejob/test/cases/test_helper_test.rb index 3d863f5e65..2398402d5d 100644 --- a/activejob/test/cases/test_helper_test.rb +++ b/activejob/test/cases/test_helper_test.rb @@ -1,17 +1,17 @@ -require 'helper' -require 'active_support/core_ext/time' -require 'active_support/core_ext/date' -require 'jobs/hello_job' -require 'jobs/logging_job' -require 'jobs/nested_job' -require 'jobs/rescue_job' -require 'models/person' +require "helper" +require "active_support/core_ext/time" +require "active_support/core_ext/date" +require "jobs/hello_job" +require "jobs/logging_job" +require "jobs/nested_job" +require "jobs/rescue_job" +require "models/person" class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_enqueued_jobs assert_nothing_raised do assert_enqueued_jobs 1 do - HelloJob.perform_later('david') + HelloJob.perform_later("david") end end end @@ -19,23 +19,23 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_repeated_enqueued_jobs_calls assert_nothing_raised do assert_enqueued_jobs 1 do - HelloJob.perform_later('abdelkader') + HelloJob.perform_later("abdelkader") end end assert_nothing_raised do assert_enqueued_jobs 2 do - HelloJob.perform_later('sean') - HelloJob.perform_later('yves') + HelloJob.perform_later("sean") + HelloJob.perform_later("yves") end end end def test_assert_enqueued_jobs_message - HelloJob.perform_later('sean') + HelloJob.perform_later("sean") e = assert_raises Minitest::Assertion do assert_enqueued_jobs 2 do - HelloJob.perform_later('sean') + HelloJob.perform_later("sean") end end assert_match "Expected: 2", e.message @@ -44,13 +44,13 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_enqueued_jobs_with_no_block assert_nothing_raised do - HelloJob.perform_later('rafael') + HelloJob.perform_later("rafael") assert_enqueued_jobs 1 end assert_nothing_raised do - HelloJob.perform_later('aaron') - HelloJob.perform_later('matthew') + HelloJob.perform_later("aaron") + HelloJob.perform_later("matthew") assert_enqueued_jobs 3 end end @@ -72,7 +72,7 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_enqueued_jobs_too_few_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_jobs 2 do - HelloJob.perform_later('xavier') + HelloJob.perform_later("xavier") end end @@ -82,8 +82,8 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_enqueued_jobs_too_many_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_jobs 1 do - HelloJob.perform_later('cristian') - HelloJob.perform_later('guillermo') + HelloJob.perform_later("cristian") + HelloJob.perform_later("guillermo") end end @@ -93,7 +93,7 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_no_enqueued_jobs_failure error = assert_raise ActiveSupport::TestCase::Assertion do assert_no_enqueued_jobs do - HelloJob.perform_later('jeremy') + HelloJob.perform_later("jeremy") end end @@ -103,7 +103,7 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_enqueued_jobs_with_only_option assert_nothing_raised do assert_enqueued_jobs 1, only: HelloJob do - HelloJob.perform_later('jeremy') + HelloJob.perform_later("jeremy") LoggingJob.perform_later end end @@ -122,7 +122,7 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_enqueued_jobs_with_only_option_and_too_few_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_jobs 5, only: HelloJob do - HelloJob.perform_later('jeremy') + HelloJob.perform_later("jeremy") 4.times { LoggingJob.perform_later } end end @@ -133,7 +133,7 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_enqueued_jobs_with_only_option_and_too_many_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_jobs 1, only: HelloJob do - 2.times { HelloJob.perform_later('jeremy') } + 2.times { HelloJob.perform_later("jeremy") } end end @@ -143,9 +143,9 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_enqueued_jobs_with_only_option_as_array assert_nothing_raised do assert_enqueued_jobs 2, only: [HelloJob, LoggingJob] do - HelloJob.perform_later('jeremy') - LoggingJob.perform_later('stewie') - RescueJob.perform_later('david') + HelloJob.perform_later("jeremy") + LoggingJob.perform_later("stewie") + RescueJob.perform_later("david") end end end @@ -161,7 +161,7 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_no_enqueued_jobs_with_only_option_failure error = assert_raise ActiveSupport::TestCase::Assertion do assert_no_enqueued_jobs only: HelloJob do - HelloJob.perform_later('jeremy') + HelloJob.perform_later("jeremy") LoggingJob.perform_later end end @@ -178,7 +178,7 @@ class EnqueuedJobsTest < ActiveJob::TestCase end def test_assert_enqueued_job - assert_enqueued_with(job: LoggingJob, queue: 'default') do + assert_enqueued_with(job: LoggingJob, queue: "default") do LoggingJob.set(wait_until: Date.tomorrow.noon).perform_later end end @@ -190,19 +190,19 @@ class EnqueuedJobsTest < ActiveJob::TestCase assert_instance_of LoggingJob, job assert_in_delta 5.minutes.from_now, job.scheduled_at, 1 - assert_equal 'default', job.queue_name + assert_equal "default", job.queue_name assert_equal [1, 2, 3], job.arguments end def test_assert_enqueued_job_failure assert_raise ActiveSupport::TestCase::Assertion do - assert_enqueued_with(job: LoggingJob, queue: 'default') do + assert_enqueued_with(job: LoggingJob, queue: "default") do NestedJob.perform_later end end error = assert_raise ActiveSupport::TestCase::Assertion do - assert_enqueued_with(job: NestedJob, queue: 'low') do + assert_enqueued_with(job: NestedJob, queue: "low") do NestedJob.perform_later end end @@ -265,7 +265,7 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_performed_jobs assert_nothing_raised do assert_performed_jobs 1 do - HelloJob.perform_later('david') + HelloJob.perform_later("david") end end end @@ -273,23 +273,23 @@ class PerformedJobsTest < ActiveJob::TestCase def test_repeated_performed_jobs_calls assert_nothing_raised do assert_performed_jobs 1 do - HelloJob.perform_later('abdelkader') + HelloJob.perform_later("abdelkader") end end assert_nothing_raised do assert_performed_jobs 2 do - HelloJob.perform_later('sean') - HelloJob.perform_later('yves') + HelloJob.perform_later("sean") + HelloJob.perform_later("yves") end end end def test_assert_performed_jobs_message - HelloJob.perform_later('sean') + HelloJob.perform_later("sean") e = assert_raises Minitest::Assertion do assert_performed_jobs 2 do - HelloJob.perform_later('sean') + HelloJob.perform_later("sean") end end assert_match "Expected: 2", e.message @@ -299,15 +299,15 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_performed_jobs_with_no_block assert_nothing_raised do perform_enqueued_jobs do - HelloJob.perform_later('rafael') + HelloJob.perform_later("rafael") end assert_performed_jobs 1 end assert_nothing_raised do perform_enqueued_jobs do - HelloJob.perform_later('aaron') - HelloJob.perform_later('matthew') + HelloJob.perform_later("aaron") + HelloJob.perform_later("matthew") assert_performed_jobs 3 end end @@ -330,7 +330,7 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_performed_jobs_too_few_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_performed_jobs 2 do - HelloJob.perform_later('xavier') + HelloJob.perform_later("xavier") end end @@ -340,8 +340,8 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_performed_jobs_too_many_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_performed_jobs 1 do - HelloJob.perform_later('cristian') - HelloJob.perform_later('guillermo') + HelloJob.perform_later("cristian") + HelloJob.perform_later("guillermo") end end @@ -351,7 +351,7 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_no_performed_jobs_failure error = assert_raise ActiveSupport::TestCase::Assertion do assert_no_performed_jobs do - HelloJob.perform_later('jeremy') + HelloJob.perform_later("jeremy") end end @@ -361,7 +361,7 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_performed_jobs_with_only_option assert_nothing_raised do assert_performed_jobs 1, only: HelloJob do - HelloJob.perform_later('jeremy') + HelloJob.perform_later("jeremy") LoggingJob.perform_later end end @@ -370,9 +370,9 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_performed_jobs_with_only_option_as_array assert_nothing_raised do assert_performed_jobs 2, only: [HelloJob, LoggingJob] do - HelloJob.perform_later('jeremy') - LoggingJob.perform_later('stewie') - RescueJob.perform_later('david') + HelloJob.perform_later("jeremy") + LoggingJob.perform_later("stewie") + RescueJob.perform_later("david") end end end @@ -390,7 +390,7 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_performed_jobs_with_only_option_and_too_few_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_performed_jobs 5, only: HelloJob do - HelloJob.perform_later('jeremy') + HelloJob.perform_later("jeremy") 4.times { LoggingJob.perform_later } end end @@ -401,7 +401,7 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_performed_jobs_with_only_option_and_too_many_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_performed_jobs 1, only: HelloJob do - 2.times { HelloJob.perform_later('jeremy') } + 2.times { HelloJob.perform_later("jeremy") } end end @@ -427,7 +427,7 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_no_performed_jobs_with_only_option_failure error = assert_raise ActiveSupport::TestCase::Assertion do assert_no_performed_jobs only: HelloJob do - HelloJob.perform_later('jeremy') + HelloJob.perform_later("jeremy") LoggingJob.perform_later end end @@ -436,20 +436,20 @@ class PerformedJobsTest < ActiveJob::TestCase end def test_assert_performed_job - assert_performed_with(job: NestedJob, queue: 'default') do + assert_performed_with(job: NestedJob, queue: "default") do NestedJob.perform_later end end def test_assert_performed_job_returns - job = assert_performed_with(job: NestedJob, queue: 'default') do + job = assert_performed_with(job: NestedJob, queue: "default") do NestedJob.perform_later end assert_instance_of NestedJob, job assert_nil job.scheduled_at assert_equal [], job.arguments - assert_equal 'default', job.queue_name + assert_equal "default", job.queue_name end def test_assert_performed_job_failure @@ -460,8 +460,8 @@ class PerformedJobsTest < ActiveJob::TestCase end assert_raise ActiveSupport::TestCase::Assertion do - assert_performed_with(job: HelloJob, queue: 'low') do - HelloJob.set(queue: 'important').perform_later + assert_performed_with(job: HelloJob, queue: "low") do + HelloJob.set(queue: "important").perform_later end end end diff --git a/activejob/test/cases/translation_test.rb b/activejob/test/cases/translation_test.rb index d5e3aaf9e3..27bfd50985 100644 --- a/activejob/test/cases/translation_test.rb +++ b/activejob/test/cases/translation_test.rb @@ -1,18 +1,18 @@ -require 'helper' -require 'jobs/translated_hello_job' +require "helper" +require "jobs/translated_hello_job" class TranslationTest < ActiveSupport::TestCase setup do JobBuffer.clear I18n.available_locales = [:en, :de] - @job = TranslatedHelloJob.new('Johannes') + @job = TranslatedHelloJob.new("Johannes") end teardown do I18n.available_locales = [:en] end - test 'it performs the job in the given locale' do + test "it performs the job in the given locale" do @job.locale = :de @job.perform_now assert_equal "Johannes says Guten Tag", JobBuffer.last_value diff --git a/activejob/test/helper.rb b/activejob/test/helper.rb index 54b6076f09..dbc7dad109 100644 --- a/activejob/test/helper.rb +++ b/activejob/test/helper.rb @@ -1,16 +1,16 @@ -require 'active_job' -require 'support/job_buffer' +require "active_job" +require "support/job_buffer" ActiveSupport.halt_callback_chains_on_return_false = false -GlobalID.app = 'aj' +GlobalID.app = "aj" -@adapter = ENV['AJ_ADAPTER'] || 'inline' +@adapter = ENV["AJ_ADAPTER"] || "inline" -if ENV['AJ_INTEGRATION_TESTS'] - require 'support/integration/helper' +if ENV["AJ_INTEGRATION_TESTS"] + require "support/integration/helper" else ActiveJob::Base.logger = Logger.new(nil) require "adapters/#{@adapter}" end -require 'active_support/testing/autorun' +require "active_support/testing/autorun" diff --git a/activejob/test/integration/queuing_test.rb b/activejob/test/integration/queuing_test.rb index ab3de3a8b9..41b6b9cd6b 100644 --- a/activejob/test/integration/queuing_test.rb +++ b/activejob/test/integration/queuing_test.rb @@ -1,17 +1,17 @@ -require 'helper' -require 'jobs/logging_job' -require 'jobs/hello_job' -require 'jobs/provider_jid_job' -require 'active_support/core_ext/numeric/time' +require "helper" +require "jobs/logging_job" +require "jobs/hello_job" +require "jobs/provider_jid_job" +require "active_support/core_ext/numeric/time" class QueuingTest < ActiveSupport::TestCase - test 'should run jobs enqueued on a listening queue' do + test "should run jobs enqueued on a listening queue" do TestJob.perform_later @id wait_for_jobs_to_finish_for(5.seconds) assert job_executed end - test 'should not run jobs queued on a non-listening queue' do + test "should not run jobs queued on a non-listening queue" do skip if adapter_is?(:inline, :async, :sucker_punch, :que) old_queue = TestJob.queue_name @@ -25,17 +25,17 @@ class QueuingTest < ActiveSupport::TestCase end end - test 'should supply a wrapped class name to Sidekiq' do + test "should supply a wrapped class name to Sidekiq" do skip unless adapter_is?(:sidekiq) Sidekiq::Testing.fake! do ::HelloJob.perform_later hash = ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper.jobs.first - assert_equal "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper", hash['class'] - assert_equal "HelloJob", hash['wrapped'] + assert_equal "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper", hash["class"] + assert_equal "HelloJob", hash["wrapped"] end end - test 'should access provider_job_id inside Sidekiq job' do + test "should access provider_job_id inside Sidekiq job" do skip unless adapter_is?(:sidekiq) Sidekiq::Testing.inline! do job = ::ProviderJidJob.perform_later @@ -43,7 +43,7 @@ class QueuingTest < ActiveSupport::TestCase end end - test 'should not run job enqueued in the future' do + test "should not run job enqueued in the future" do begin TestJob.set(wait: 10.minutes).perform_later @id wait_for_jobs_to_finish_for(5.seconds) @@ -53,7 +53,7 @@ class QueuingTest < ActiveSupport::TestCase end end - test 'should run job enqueued in the future at the specified time' do + test "should run job enqueued in the future at the specified time" do begin TestJob.set(wait: 5.seconds).perform_later @id wait_for_jobs_to_finish_for(2.seconds) @@ -65,19 +65,19 @@ class QueuingTest < ActiveSupport::TestCase end end - test 'should supply a provider_job_id when available for immediate jobs' do + test "should supply a provider_job_id when available for immediate jobs" do skip unless adapter_is?(:async, :delayed_job, :sidekiq, :qu, :que, :queue_classic) test_job = TestJob.perform_later @id - assert test_job.provider_job_id, 'Provider job id should be set by provider' + assert test_job.provider_job_id, "Provider job id should be set by provider" end - test 'should supply a provider_job_id when available for delayed jobs' do + test "should supply a provider_job_id when available for delayed jobs" do skip unless adapter_is?(:async, :delayed_job, :sidekiq, :que, :queue_classic) delayed_test_job = TestJob.set(wait: 1.minute).perform_later @id - assert delayed_test_job.provider_job_id, 'Provider job id should by set for delayed jobs by provider' + assert delayed_test_job.provider_job_id, "Provider job id should by set for delayed jobs by provider" end - test 'current locale is kept while running perform_later' do + test "current locale is kept while running perform_later" do skip if adapter_is?(:inline) begin @@ -87,14 +87,14 @@ class QueuingTest < ActiveSupport::TestCase TestJob.perform_later @id wait_for_jobs_to_finish_for(5.seconds) assert job_executed - assert_equal 'de', job_executed_in_locale + assert_equal "de", job_executed_in_locale ensure I18n.available_locales = [:en] I18n.locale = :en end end - test 'should run job with higher priority first' do + test "should run job with higher priority first" do skip unless adapter_is?(:delayed_job, :que) wait_until = Time.now + 3.seconds diff --git a/activejob/test/jobs/gid_job.rb b/activejob/test/jobs/gid_job.rb index e485bfa2dd..42484dc198 100644 --- a/activejob/test/jobs/gid_job.rb +++ b/activejob/test/jobs/gid_job.rb @@ -1,4 +1,4 @@ -require_relative '../support/job_buffer' +require_relative "../support/job_buffer" class GidJob < ActiveJob::Base def perform(person) diff --git a/activejob/test/jobs/hello_job.rb b/activejob/test/jobs/hello_job.rb index 022fa58e4a..126fefae00 100644 --- a/activejob/test/jobs/hello_job.rb +++ b/activejob/test/jobs/hello_job.rb @@ -1,4 +1,4 @@ -require_relative '../support/job_buffer' +require_relative "../support/job_buffer" class HelloJob < ActiveJob::Base def perform(greeter = "David") diff --git a/activejob/test/jobs/kwargs_job.rb b/activejob/test/jobs/kwargs_job.rb index 2df17d15ae..9f9d809673 100644 --- a/activejob/test/jobs/kwargs_job.rb +++ b/activejob/test/jobs/kwargs_job.rb @@ -1,4 +1,4 @@ -require_relative '../support/job_buffer' +require_relative "../support/job_buffer" class KwargsJob < ActiveJob::Base def perform(argument: 1) diff --git a/activejob/test/jobs/provider_jid_job.rb b/activejob/test/jobs/provider_jid_job.rb index e4f585fa94..0c8ba040f5 100644 --- a/activejob/test/jobs/provider_jid_job.rb +++ b/activejob/test/jobs/provider_jid_job.rb @@ -1,4 +1,4 @@ -require_relative '../support/job_buffer' +require_relative "../support/job_buffer" class ProviderJidJob < ActiveJob::Base def perform diff --git a/activejob/test/jobs/queue_as_job.rb b/activejob/test/jobs/queue_as_job.rb index 897aef52e5..7dc318e736 100644 --- a/activejob/test/jobs/queue_as_job.rb +++ b/activejob/test/jobs/queue_as_job.rb @@ -1,4 +1,4 @@ -require_relative '../support/job_buffer' +require_relative "../support/job_buffer" class QueueAsJob < ActiveJob::Base MY_QUEUE = :low_priority diff --git a/activejob/test/jobs/rescue_job.rb b/activejob/test/jobs/rescue_job.rb index 4f6376c850..ef8f777437 100644 --- a/activejob/test/jobs/rescue_job.rb +++ b/activejob/test/jobs/rescue_job.rb @@ -1,16 +1,16 @@ -require_relative '../support/job_buffer' +require_relative "../support/job_buffer" class RescueJob < ActiveJob::Base class OtherError < StandardError; end rescue_from(ArgumentError) do - JobBuffer.add('rescued from ArgumentError') + JobBuffer.add("rescued from ArgumentError") arguments[0] = "DIFFERENT!" retry_job end rescue_from(ActiveJob::DeserializationError) do |e| - JobBuffer.add('rescued from DeserializationError') + JobBuffer.add("rescued from DeserializationError") JobBuffer.add("DeserializationError original exception was #{e.cause.class.name}") end @@ -21,7 +21,7 @@ class RescueJob < ActiveJob::Base when "other" raise OtherError else - JobBuffer.add('performed beautifully') + JobBuffer.add("performed beautifully") end end end diff --git a/activejob/test/jobs/retry_job.rb b/activejob/test/jobs/retry_job.rb index 350edee61c..be20156984 100644 --- a/activejob/test/jobs/retry_job.rb +++ b/activejob/test/jobs/retry_job.rb @@ -1,5 +1,5 @@ -require_relative '../support/job_buffer' -require 'active_support/core_ext/integer/inflections' +require_relative "../support/job_buffer" +require "active_support/core_ext/integer/inflections" class DefaultsError < StandardError; end class LongWaitError < StandardError; end diff --git a/activejob/test/jobs/translated_hello_job.rb b/activejob/test/jobs/translated_hello_job.rb index 9657cd3f54..56e9f147b9 100644 --- a/activejob/test/jobs/translated_hello_job.rb +++ b/activejob/test/jobs/translated_hello_job.rb @@ -1,8 +1,8 @@ -require_relative '../support/job_buffer' +require_relative "../support/job_buffer" class TranslatedHelloJob < ActiveJob::Base def perform(greeter = "David") - translations = { en: 'Hello', de: 'Guten Tag' } + translations = { en: "Hello", de: "Guten Tag" } hello = translations[I18n.locale] JobBuffer.add("#{greeter} says #{hello}") diff --git a/activejob/test/support/backburner/inline.rb b/activejob/test/support/backburner/inline.rb index f761b53e27..7b7954e8f7 100644 --- a/activejob/test/support/backburner/inline.rb +++ b/activejob/test/support/backburner/inline.rb @@ -1,4 +1,4 @@ -require 'backburner' +require "backburner" Backburner::Worker.class_eval do class << self; alias_method :original_enqueue, :enqueue; end diff --git a/activejob/test/support/delayed_job/delayed/backend/test.rb b/activejob/test/support/delayed_job/delayed/backend/test.rb index f80ec3a5a6..e4aca625cd 100644 --- a/activejob/test/support/delayed_job/delayed/backend/test.rb +++ b/activejob/test/support/delayed_job/delayed/backend/test.rb @@ -1,5 +1,5 @@ #copied from https://github.com/collectiveidea/delayed_job/blob/master/spec/delayed/backend/test.rb -require 'ostruct' +require "ostruct" # An in-memory backend suitable only for testing. Tries to behave as if it were an ORM. module Delayed diff --git a/activejob/test/support/integration/adapters/delayed_job.rb b/activejob/test/support/integration/adapters/delayed_job.rb index 0b591964bc..2adbbcd88f 100644 --- a/activejob/test/support/integration/adapters/delayed_job.rb +++ b/activejob/test/support/integration/adapters/delayed_job.rb @@ -1,5 +1,5 @@ -require 'delayed_job' -require 'delayed_job_active_record' +require "delayed_job" +require "delayed_job_active_record" module DelayedJobJobsManager def setup diff --git a/activejob/test/support/integration/adapters/qu.rb b/activejob/test/support/integration/adapters/qu.rb index 256ddb3cf3..71819f5a55 100644 --- a/activejob/test/support/integration/adapters/qu.rb +++ b/activejob/test/support/integration/adapters/qu.rb @@ -1,9 +1,9 @@ module QuJobsManager def setup - require 'qu-rails' - require 'qu-redis' + require "qu-rails" + require "qu-redis" ActiveJob::Base.queue_adapter = :qu - ENV['REDISTOGO_URL'] = "redis://127.0.0.1:6379/12" + ENV["REDISTOGO_URL"] = "redis://127.0.0.1:6379/12" backend = Qu::Backend::Redis.new backend.namespace = "active_jobs_int_test" Qu.backend = backend diff --git a/activejob/test/support/integration/adapters/que.rb b/activejob/test/support/integration/adapters/que.rb index 0cd8952a28..3d35a0439f 100644 --- a/activejob/test/support/integration/adapters/que.rb +++ b/activejob/test/support/integration/adapters/que.rb @@ -1,6 +1,6 @@ module QueJobsManager def setup - require 'sequel' + require "sequel" ActiveJob::Base.queue_adapter = :que Que.mode = :off Que.worker_count = 1 @@ -11,9 +11,9 @@ module QueJobsManager end def start_workers - que_url = ENV['QUE_DATABASE_URL'] || 'postgres:///active_jobs_que_int_test' + que_url = ENV["QUE_DATABASE_URL"] || "postgres:///active_jobs_que_int_test" uri = URI.parse(que_url) - user = uri.user||ENV['USER'] + user = uri.user||ENV["USER"] pass = uri.password db = uri.path[1..-1] %x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -c 'drop database if exists "#{db}"' -U #{user} -t template1} diff --git a/activejob/test/support/integration/adapters/queue_classic.rb b/activejob/test/support/integration/adapters/queue_classic.rb index 29c04bf625..b5d831428e 100644 --- a/activejob/test/support/integration/adapters/queue_classic.rb +++ b/activejob/test/support/integration/adapters/queue_classic.rb @@ -1,8 +1,8 @@ module QueueClassicJobsManager def setup - ENV['QC_DATABASE_URL'] ||= 'postgres:///active_jobs_qc_int_test' - ENV['QC_RAILS_DATABASE'] = 'false' - ENV['QC_LISTEN_TIME'] = "0.5" + ENV["QC_DATABASE_URL"] ||= "postgres:///active_jobs_qc_int_test" + ENV["QC_RAILS_DATABASE"] = "false" + ENV["QC_LISTEN_TIME"] = "0.5" ActiveJob::Base.queue_adapter = :queue_classic end @@ -11,8 +11,8 @@ module QueueClassicJobsManager end def start_workers - uri = URI.parse(ENV['QC_DATABASE_URL']) - user = uri.user||ENV['USER'] + uri = URI.parse(ENV["QC_DATABASE_URL"]) + user = uri.user||ENV["USER"] pass = uri.password db = uri.path[1..-1] %x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -c 'drop database if exists "#{db}"' -U #{user} -t template1} @@ -22,7 +22,7 @@ module QueueClassicJobsManager QC.default_conn_adapter.disconnect QC.default_conn_adapter = nil @pid = fork do - worker = QC::Worker.new(q_name: 'integration_tests') + worker = QC::Worker.new(q_name: "integration_tests") worker.start end @@ -32,6 +32,6 @@ module QueueClassicJobsManager end def stop_workers - Process.kill 'HUP', @pid + Process.kill "HUP", @pid end end diff --git a/activejob/test/support/integration/adapters/resque.rb b/activejob/test/support/integration/adapters/resque.rb index 912f4bc387..cb1e376364 100644 --- a/activejob/test/support/integration/adapters/resque.rb +++ b/activejob/test/support/integration/adapters/resque.rb @@ -1,7 +1,7 @@ module ResqueJobsManager def setup ActiveJob::Base.queue_adapter = :resque - Resque.redis = Redis::Namespace.new 'active_jobs_int_test', redis: Redis.connect(url: "redis://127.0.0.1:6379/12", :thread_safe => true) + Resque.redis = Redis::Namespace.new "active_jobs_int_test", redis: Redis.connect(url: "redis://127.0.0.1:6379/12", :thread_safe => true) Resque.logger = Rails.logger unless can_run? puts "Cannot run integration tests for resque. To be able to run integration tests for resque you need to install and start redis.\n" diff --git a/activejob/test/support/integration/adapters/sidekiq.rb b/activejob/test/support/integration/adapters/sidekiq.rb index 2f19d7dacc..9d0f2d0bf3 100644 --- a/activejob/test/support/integration/adapters/sidekiq.rb +++ b/activejob/test/support/integration/adapters/sidekiq.rb @@ -1,6 +1,6 @@ -require 'sidekiq/api' +require "sidekiq/api" -require 'sidekiq/testing' +require "sidekiq/testing" Sidekiq::Testing.disable! module SidekiqJobsManager @@ -29,7 +29,7 @@ module SidekiqJobsManager # Sidekiq is not warning-clean :( $VERBOSE = false - $stdin.reopen('/dev/null') + $stdin.reopen("/dev/null") $stdout.sync = true $stderr.sync = true @@ -49,7 +49,7 @@ module SidekiqJobsManager self_write.puts("TERM") end - require 'sidekiq/launcher' + require "sidekiq/launcher" sidekiq = Sidekiq::Launcher.new({queues: ["integration_tests"], environment: "test", concurrency: 1, @@ -79,7 +79,7 @@ module SidekiqJobsManager def stop_workers if @pid - Process.kill 'TERM', @pid + Process.kill "TERM", @pid Process.wait @pid end end diff --git a/activejob/test/support/integration/adapters/sneakers.rb b/activejob/test/support/integration/adapters/sneakers.rb index 875803a2d8..71e32a3cdd 100644 --- a/activejob/test/support/integration/adapters/sneakers.rb +++ b/activejob/test/support/integration/adapters/sneakers.rb @@ -1,6 +1,6 @@ -require 'sneakers/runner' -require 'sneakers/publisher' -require 'timeout' +require "sneakers/runner" +require "sneakers/publisher" +require "timeout" module Sneakers class Publisher @@ -17,9 +17,9 @@ module SneakersJobsManager def setup ActiveJob::Base.queue_adapter = :sneakers Sneakers.configure :heartbeat => 2, - :amqp => 'amqp://guest:guest@localhost:5672', - :vhost => '/', - :exchange => 'active_jobs_sneakers_int_test', + :amqp => "amqp://guest:guest@localhost:5672", + :vhost => "/", + :exchange => "active_jobs_sneakers_int_test", :exchange_type => :direct, :daemonize => true, :threads => 1, @@ -60,8 +60,8 @@ module SneakersJobsManager end def stop_workers - Process.kill 'TERM', @pid - Process.kill 'TERM', File.open(Rails.root.join("tmp/sneakers.pid").to_s).read.to_i + Process.kill "TERM", @pid + Process.kill "TERM", File.open(Rails.root.join("tmp/sneakers.pid").to_s).read.to_i rescue end diff --git a/activejob/test/support/integration/dummy_app_template.rb b/activejob/test/support/integration/dummy_app_template.rb index a0ef38b0b2..62f6fa13f6 100644 --- a/activejob/test/support/integration/dummy_app_template.rb +++ b/activejob/test/support/integration/dummy_app_template.rb @@ -1,19 +1,19 @@ -if ENV['AJ_ADAPTER'] == 'delayed_job' +if ENV["AJ_ADAPTER"] == "delayed_job" generate "delayed_job:active_record", "--quiet" end rails_command("db:migrate") -initializer 'activejob.rb', <<-CODE +initializer "activejob.rb", <<-CODE require "#{File.expand_path("../jobs_manager.rb", __FILE__)}" JobsManager.current_manager.setup CODE -initializer 'i18n.rb', <<-CODE +initializer "i18n.rb", <<-CODE I18n.available_locales = [:en, :de] CODE -file 'app/jobs/test_job.rb', <<-CODE +file "app/jobs/test_job.rb", <<-CODE class TestJob < ActiveJob::Base queue_as :integration_tests diff --git a/activejob/test/support/integration/helper.rb b/activejob/test/support/integration/helper.rb index 4a1b0bfbcb..1aaee2c809 100644 --- a/activejob/test/support/integration/helper.rb +++ b/activejob/test/support/integration/helper.rb @@ -3,7 +3,7 @@ puts "\n\n*** rake aj:integration:#{ENV['AJ_ADAPTER']} ***\n" ENV["RAILS_ENV"] = "test" ActiveJob::Base.queue_name_prefix = nil -require 'rails/generators/rails/app/app_generator' +require "rails/generators/rails/app/app_generator" dummy_app_path = Dir.mktmpdir + "/dummy" dummy_app_template = File.expand_path("../dummy_app_template.rb", __FILE__) @@ -14,12 +14,12 @@ Rails::Generators::AppGenerator.start args require "#{dummy_app_path}/config/environment.rb" -ActiveRecord::Migrator.migrations_paths = [ Rails.root.join('db/migrate').to_s ] -require 'rails/test_help' +ActiveRecord::Migrator.migrations_paths = [ Rails.root.join("db/migrate").to_s ] +require "rails/test_help" Rails.backtrace_cleaner.remove_silencers! -require_relative 'test_case_helpers' +require_relative "test_case_helpers" ActiveSupport::TestCase.include(TestCaseHelpers) JobsManager.current_manager.start_workers diff --git a/activejob/test/support/integration/jobs_manager.rb b/activejob/test/support/integration/jobs_manager.rb index 78d48e8d9a..488756437b 100644 --- a/activejob/test/support/integration/jobs_manager.rb +++ b/activejob/test/support/integration/jobs_manager.rb @@ -3,7 +3,7 @@ class JobsManager attr :adapter_name def self.current_manager - @@managers[ENV['AJ_ADAPTER']] ||= new(ENV['AJ_ADAPTER']) + @@managers[ENV["AJ_ADAPTER"]] ||= new(ENV["AJ_ADAPTER"]) end def initialize(adapter_name) diff --git a/activejob/test/support/integration/test_case_helpers.rb b/activejob/test/support/integration/test_case_helpers.rb index fdf25c67a1..4c4c56c9da 100644 --- a/activejob/test/support/integration/test_case_helpers.rb +++ b/activejob/test/support/integration/test_case_helpers.rb @@ -1,6 +1,6 @@ -require 'active_support/concern' -require 'active_support/core_ext/string/inflections' -require 'support/integration/jobs_manager' +require "active_support/concern" +require "active_support/core_ext/string/inflections" +require "support/integration/jobs_manager" module TestCaseHelpers extend ActiveSupport::Concern @@ -29,7 +29,7 @@ module TestCaseHelpers end def adapter_is?(*adapter_class_symbols) - adapter = ActiveJob::Base.queue_adapter.class.name.demodulize.chomp('Adapter').underscore + adapter = ActiveJob::Base.queue_adapter.class.name.demodulize.chomp("Adapter").underscore adapter_class_symbols.map(&:to_s).include? adapter end diff --git a/activejob/test/support/que/inline.rb b/activejob/test/support/que/inline.rb index 0950e52d28..ea9999b473 100644 --- a/activejob/test/support/que/inline.rb +++ b/activejob/test/support/que/inline.rb @@ -1,4 +1,4 @@ -require 'que' +require "que" Que::Job.class_eval do class << self; alias_method :original_enqueue, :enqueue; end diff --git a/activejob/test/support/queue_classic/inline.rb b/activejob/test/support/queue_classic/inline.rb index 5743d5bbb5..dcd834ecce 100644 --- a/activejob/test/support/queue_classic/inline.rb +++ b/activejob/test/support/queue_classic/inline.rb @@ -1,21 +1,21 @@ -require 'queue_classic' +require "queue_classic" module QC class Queue def enqueue(method, *args) - receiver_str, _, message = method.rpartition('.') + receiver_str, _, message = method.rpartition(".") receiver = eval(receiver_str) receiver.send(message, *args) end def enqueue_in(seconds, method, *args) - receiver_str, _, message = method.rpartition('.') + receiver_str, _, message = method.rpartition(".") receiver = eval(receiver_str) receiver.send(message, *args) end def enqueue_at(not_before, method, *args) - receiver_str, _, message = method.rpartition('.') + receiver_str, _, message = method.rpartition(".") receiver = eval(receiver_str) receiver.send(message, *args) end diff --git a/activejob/test/support/sneakers/inline.rb b/activejob/test/support/sneakers/inline.rb index 16d9b830fa..3cdc54e6d5 100644 --- a/activejob/test/support/sneakers/inline.rb +++ b/activejob/test/support/sneakers/inline.rb @@ -1,4 +1,4 @@ -require 'sneakers' +require "sneakers" module Sneakers module Worker |