# frozen_string_literal: true

puts "\n\n*** rake aj:integration:#{ENV['AJ_ADAPTER']} ***\n"

ENV["RAILS_ENV"] = "test"
ActiveJob::Base.queue_name_prefix = nil

require "rails/generators/rails/app/app_generator"

require "tmpdir"
dummy_app_path     = Dir.mktmpdir + "/dummy"
dummy_app_template = File.expand_path("dummy_app_template.rb",  __dir__)
args = Rails::Generators::ARGVScrubber.new(["new", dummy_app_path, "--skip-gemfile", "--skip-bundle",
  "--skip-git", "--skip-spring", "-d", "sqlite3", "--skip-javascript", "--force", "--quiet",
  "--template", dummy_app_template]).prepare!
Rails::Generators::AppGenerator.start args

require "#{dummy_app_path}/config/environment.rb"

ActiveRecord::Migrator.migrations_paths = [ Rails.root.join("db/migrate").to_s ]
ActiveRecord::Tasks::DatabaseTasks.migrate
require "rails/test_help"

Rails.backtrace_cleaner.remove_silencers!

require_relative "test_case_helpers"
ActiveSupport::TestCase.include(TestCaseHelpers)

JobsManager.current_manager.start_workers

Minitest.after_run do
  JobsManager.current_manager.stop_workers
  JobsManager.current_manager.clear_jobs
end

# frozen_string_literal: true

puts "\n\n*** rake test:integration:#{ENV['AJ_ADAPTER']} ***\n"

ENV["RAILS_ENV"] = "test"
ActiveJob::Base.queue_name_prefix = nil

require "rails/generators/rails/app/app_generator"

require "tmpdir"
dummy_app_path     = Dir.mktmpdir + "/dummy"
dummy_app_template = File.expand_path("dummy_app_template.rb",  __dir__)
args = Rails::Generators::ARGVScrubber.new(["new", dummy_app_path, "--skip-gemfile", "--skip-bundle",
  "--skip-git", "--skip-spring", "-d", "sqlite3", "--skip-javascript", "--force", "--quiet",
  "--template", dummy_app_template]).prepare!
Rails::Generators::AppGenerator.start args

require "#{dummy_app_path}/config/environment.rb"

ActiveRecord::Migrator.migrations_paths = [ Rails.root.join("db/migrate").to_s ]
ActiveRecord::Tasks::DatabaseTasks.migrate
require "rails/test_help"

Rails.backtrace_cleaner.remove_silencers!

require_relative "test_case_helpers"
ActiveSupport::TestCase.include(TestCaseHelpers)

JobsManager.current_manager.start_workers

Minitest.after_run do
  JobsManager.current_manager.stop_workers
  JobsManager.current_manager.clear_jobs
end

Print correct rake command on running AJ integration tests
Print correct rake command on running AJ integration tests

Currently when executing `bundle exec rake test:integration` under `activejob/`
derectory, it prints helpful info like:
```
(snip)
*** rake aj:integration:async ***
(snip)
*** rake aj:integration:delayed_job ***
(snip)
 ```
but  there is no defined `:aj` scope  in `activejob/Rakefile`,
so I think output should be like:
```
(snip)
*** rake test:integration:async ***
(snip)
*** rake test:integration:delayed_job ***
(snip)
 ```

By the way `rake test:integration` doesn't work if execute it without
prepending `bundle exec` to that command. It is probably what we should
fix too.
