Skip to content

Commit

Permalink
Deprecate Runner.new.run in favour of Runner.run
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianna-chang-shopify committed Feb 11, 2021
1 parent 00b6d37 commit 786e894
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 786e894

Please sign in to comment.