Skip to content

Commit

Permalink
Expanding heroku flag spec to ensure the global state isn't mangled b…
Browse files Browse the repository at this point in the history
…y the subprocess
  • Loading branch information
iloveitaly committed Sep 7, 2018
1 parent 6bc461e commit 869e995
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions spec/resque/heroku_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def self.perform(uuid)
end
end

def LongCleanupJob
class LongCleanupJob
def self.perform(uuid)
sleep 2

Expand Down Expand Up @@ -110,8 +110,21 @@ def wait(timeout: 5000, condition:)
@worker.shutdown
thread.join

# if worker will terminate, then the file is written
expect(File.exist?(@uuid)).to eq(true)
# if worker will terminate, then the file is written if the heroku flag is set
expect(File.exist?(@uuid)).to be true
File.delete(@uuid)

# however, this should not effect the flag on the main process or the next
expect(Resque.heroku_will_terminate?).to be false

thread = Thread.new { @worker.work(0.1) { puts "hello" } }

Resque::Job.create(:jobs, LongCleanupJob, @uuid)

@worker.shutdown
thread.join

expect(File.exist?(@uuid)).to be false
end
end
end

0 comments on commit 869e995

Please sign in to comment.