Avoid race condition in AJ integration tests
Make sure the file doesn't exist until we've finished writing it.
This commit is contained in:
parent
160387bca4
commit
0e97cd1a0d
|
@ -18,12 +18,13 @@ class TestJob < ActiveJob::Base
|
|||
queue_as :integration_tests
|
||||
|
||||
def perform(x)
|
||||
File.open(Rails.root.join("tmp/\#{x}"), "wb+") do |f|
|
||||
File.open(Rails.root.join("tmp/\#{x}.new"), "wb+") do |f|
|
||||
f.write Marshal.dump({
|
||||
"locale" => I18n.locale.to_s || "en",
|
||||
"executed_at" => Time.now.to_r
|
||||
})
|
||||
end
|
||||
File.rename(Rails.root.join("tmp/\#{x}.new"), Rails.root.join("tmp/\#{x}"))
|
||||
end
|
||||
end
|
||||
CODE
|
||||
|
|
|
@ -5,6 +5,7 @@ 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", __FILE__)
|
||||
args = Rails::Generators::ARGVScrubber.new(["new", dummy_app_path, "--skip-gemfile", "--skip-bundle",
|
||||
|
|
Loading…
Reference in New Issue