mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix duplicated suffix for JobGenerator
This commit is contained in:
parent
7452351815
commit
8e2c91df4a
3 changed files with 19 additions and 0 deletions
|
@ -28,6 +28,10 @@ module Rails # :nodoc:
|
|||
end
|
||||
|
||||
private
|
||||
def file_name
|
||||
@_file_name ||= super.gsub(/_job/i, "")
|
||||
end
|
||||
|
||||
def application_job_file_name
|
||||
@application_job_file_name ||= if mountable_engine?
|
||||
"app/jobs/#{namespaced_path}/application_job.rb"
|
||||
|
|
|
@ -10,6 +10,11 @@ module TestUnit # :nodoc:
|
|||
def create_test_file
|
||||
template "unit_test.rb", File.join("test/jobs", class_path, "#{file_name}_job_test.rb")
|
||||
end
|
||||
|
||||
private
|
||||
def file_name
|
||||
@_file_name ||= super.gsub(/_job/i, "")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,4 +35,14 @@ class JobGeneratorTest < Rails::Generators::TestCase
|
|||
assert_match(/class ApplicationJob < ActiveJob::Base/, job)
|
||||
end
|
||||
end
|
||||
|
||||
def test_job_suffix_is_not_duplicated
|
||||
run_generator ["notifier_job"]
|
||||
|
||||
assert_no_file "app/jobs/notifier_job_job.rb"
|
||||
assert_file "app/jobs/notifier_job.rb"
|
||||
|
||||
assert_no_file "test/jobs/notifier_job_job_test.rb"
|
||||
assert_file "test/jobs/notifier_job_test.rb"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue