Skip to content

Commit

Permalink
Test to ensure that including extend Resque::Plugins::Meta doesn't …
Browse files Browse the repository at this point in the history
…break things
  • Loading branch information
idris committed Aug 24, 2010
1 parent 378348a commit a3d2ac8
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/progress_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ def self.perform(meta_id)
at(5, 5, 'complete')
end
end

class IncludeBothJob
extend Resque::Plugins::Meta
extend Resque::Plugins::Progress
@queue = :test

def self.expire_meta_in
10
end

def self.perform(meta_id)
(0..4).each do |i|
at(i, 5, 'working')
end
at(5, 5, 'complete')
end
end


class ProgressTest < Test::Unit::TestCase
def setup
Resque.redis.flushall
Expand Down Expand Up @@ -67,4 +86,26 @@ def test_final_progress
assert_equal(100, meta.progress[:percent])
assert_equal('complete', meta.progress[:message])
end

def test_include_both
meta = IncludeBothJob.enqueue
assert_not_nil(meta)
assert_not_nil(meta.progress)
assert_equal(0, meta.progress[:num])
assert_equal(1, meta.progress[:total])
assert_equal(0, meta.progress[:percent])
assert_nil(meta.progress[:message])

worker = Resque::Worker.new(:test)
worker.work(0)

meta = IncludeBothJob.get_meta(meta.meta_id)
assert_not_nil(meta)
assert(meta.finished?)
assert_not_nil(meta.progress)
assert_equal(5, meta.progress[:num])
assert_equal(5, meta.progress[:total])
assert_equal(100, meta.progress[:percent])
assert_equal('complete', meta.progress[:message])
end
end

0 comments on commit a3d2ac8

Please sign in to comment.