Skip to content

Commit

Permalink
Merge pull request #331 from Shopify/fix-incompability-on-runner-run
Browse files Browse the repository at this point in the history
Deprecate Runner.new.run in favour of Runner.run
  • Loading branch information
adrianna-chang-shopify authored Feb 11, 2021
2 parents 00b6d37 + 133320d commit 06a3102
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/models/maintenance_tasks/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ module MaintenanceTasks
module Runner
extend self

# @deprecated Use {Runner} directly instead.
def new
ActiveSupport::Deprecation.warn(
'Use Runner.run instead of Runner.new.run'
)
self
end

# Exception raised when a Task Job couldn't be enqueued.
class EnqueuingError < StandardError
# Initializes a Enqueuing Error.
Expand Down
7 changes: 7 additions & 0 deletions test/models/maintenance_tasks/runner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,12 @@ class RunnerTest < ActiveSupport::TestCase
assert_predicate run.csv_file, :attached?
assert_equal File.read(csv_file), run.csv_file.download
end

test '#new raises deprecation warning and returns self' do
dep_msg = 'Use Runner.run instead of Runner.new.run'
assert_deprecated(dep_msg) do
assert_equal Runner, Runner.new
end
end
end
end

0 comments on commit 06a3102

Please sign in to comment.