[ActiveJob] Add hook for test_framework and test templates

This commit is contained in:
Abdelkader Boudih 2014-08-22 19:30:36 +00:00
parent b47d8dea25
commit e63a02ccfb
3 changed files with 26 additions and 2 deletions

View File

@ -7,12 +7,14 @@ module Rails
class_option :queue, type: :string, default: 'default', desc: 'The queue name for the generated job' 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 def self.default_generator_root
File.dirname(__FILE__) File.dirname(__FILE__)
end end
check_class_collision suffix: 'Job'
def create_job_file def create_job_file
template 'job.rb', File.join('app/jobs', class_path, "#{file_name}_job.rb") template 'job.rb', File.join('app/jobs', class_path, "#{file_name}_job.rb")
end end

View File

@ -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

View File

@ -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 -%>