2017-08-14 13:08:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 13:16:09 -04:00
|
|
|
require "generators/generators_test_helper"
|
|
|
|
require "rails/generators/job/job_generator"
|
2014-12-07 00:29:12 -05:00
|
|
|
|
|
|
|
class JobGeneratorTest < Rails::Generators::TestCase
|
|
|
|
include GeneratorsTestHelper
|
|
|
|
|
|
|
|
def test_job_skeleton_is_created
|
|
|
|
run_generator ["refresh_counters"]
|
|
|
|
assert_file "app/jobs/refresh_counters_job.rb" do |job|
|
2015-02-22 15:52:58 -05:00
|
|
|
assert_match(/class RefreshCountersJob < ApplicationJob/, job)
|
2014-12-07 00:29:12 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_job_queue_param
|
|
|
|
run_generator ["refresh_counters", "--queue", "important"]
|
|
|
|
assert_file "app/jobs/refresh_counters_job.rb" do |job|
|
2015-02-22 15:52:58 -05:00
|
|
|
assert_match(/class RefreshCountersJob < ApplicationJob/, job)
|
2014-12-07 00:29:12 -05:00
|
|
|
assert_match(/queue_as :important/, job)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_job_namespace
|
|
|
|
run_generator ["admin/refresh_counters", "--queue", "admin"]
|
|
|
|
assert_file "app/jobs/admin/refresh_counters_job.rb" do |job|
|
2015-02-22 15:52:58 -05:00
|
|
|
assert_match(/class Admin::RefreshCountersJob < ApplicationJob/, job)
|
2014-12-07 00:29:12 -05:00
|
|
|
assert_match(/queue_as :admin/, job)
|
|
|
|
end
|
|
|
|
end
|
2016-03-12 01:00:55 -05:00
|
|
|
|
|
|
|
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
|
2014-12-07 00:29:12 -05:00
|
|
|
end
|