From 9a9fc01af08b5095de5b6f4f74ffd9dea7759500 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sat, 12 Mar 2016 15:00:55 +0900 Subject: generate ApplicationJob if it does not already exist ActiveJob jobs now inherit from ApplicationJob by default. However, when updating to Rails 5 from the old Rails, since there is a possibility that ApplicationJob does not exist. --- railties/test/generators/job_generator_test.rb | 7 +++++++ railties/test/generators/plugin_generator_test.rb | 13 +++++++++++++ 2 files changed, 20 insertions(+) (limited to 'railties/test') diff --git a/railties/test/generators/job_generator_test.rb b/railties/test/generators/job_generator_test.rb index 7fd8f2062f..dbff0ab704 100644 --- a/railties/test/generators/job_generator_test.rb +++ b/railties/test/generators/job_generator_test.rb @@ -26,4 +26,11 @@ class JobGeneratorTest < Rails::Generators::TestCase assert_match(/queue_as :admin/, job) end end + + def test_application_job_skeleton_is_created + run_generator ["refresh_counters"] + assert_file "app/jobs/application_job.rb" do |job| + assert_match(/class ApplicationJob < ActiveJob::Base/, job) + end + end end diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb index 17a2c6a327..3cc8e1de55 100644 --- a/railties/test/generators/plugin_generator_test.rb +++ b/railties/test/generators/plugin_generator_test.rb @@ -669,6 +669,19 @@ class PluginGeneratorTest < Rails::Generators::TestCase end end + def test_generate_application_job_when_does_not_exist_in_mountable_engine + run_generator [destination_root, '--mountable'] + FileUtils.rm "#{destination_root}/app/jobs/bukkits/application_job.rb" + capture(:stdout) do + `#{destination_root}/bin/rails g job refresh_counters` + end + + assert_file "#{destination_root}/app/jobs/bukkits/application_job.rb" do |record| + assert_match(/module Bukkits/, record) + assert_match(/class ApplicationJob < ActiveJob::Base/, record) + end + end + def test_after_bundle_callback path = 'http://example.org/rails_template' template = %{ after_bundle { run 'echo ran after_bundle' } } -- cgit v1.2.3