Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Runner.new.run in favour of Runner.run #331

Merged
merged 1 commit into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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