Browse files

Merge pull request #16648 from seuros/master

[ActiveJob] Add hook for test_framework
  • Loading branch information...
2 parents b47d8de + e63a02c commit 7df8a0d463ab4f2bc6a5d427cb6faa188b6354ab @rafaelfranca rafaelfranca committed Aug 22, 2014
View
6 activejob/lib/rails/generators/job/job_generator.rb
@@ -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
View
13 railties/lib/rails/generators/test_unit/job/job_generator.rb
@@ -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
9 railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.erb
@@ -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 -%>

0 comments on commit 7df8a0d

Please sign in to comment.