mirror of https://github.com/rails/rails
[ActiveJob] Add hook for test_framework and test templates
This commit is contained in:
parent
b47d8dea25
commit
e63a02ccfb
|
@ -7,12 +7,14 @@ module Rails
|
|||
|
||||
class_option :queue, type: :string, default: 'default', desc: 'The queue name for the generated job'
|
||||
|
||||
check_class_collision suffix: 'Job'
|
||||
|
||||
hook_for :test_framework
|
||||
|
||||
def self.default_generator_root
|
||||
File.dirname(__FILE__)
|
||||
end
|
||||
|
||||
check_class_collision suffix: 'Job'
|
||||
|
||||
def create_job_file
|
||||
template 'job.rb', File.join('app/jobs', class_path, "#{file_name}_job.rb")
|
||||
end
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
require 'rails/generators/test_unit'
|
||||
|
||||
module TestUnit # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
class JobGenerator < Base # :nodoc:
|
||||
check_class_collision suffix: 'JobTest'
|
||||
|
||||
def create_test_file
|
||||
template 'unit_test.rb.erb', File.join('test/job', class_path, "#{file_name}_test.rb")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
require 'test_helper'
|
||||
|
||||
<% module_namespacing do -%>
|
||||
class <%= class_name %>JobTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
<% end -%>
|
Loading…
Reference in New Issue