提交 e63a02cc 编写于 作者: A Abdelkader Boudih

[ActiveJob] Add hook for test_framework and test templates

上级 b47d8dea
......@@ -7,12 +7,14 @@ class JobGenerator < Rails::Generators::NamedBase # :nodoc:
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
......
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
require 'test_helper'
<% module_namespacing do -%>
class <%= class_name %>JobTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
<% end -%>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册