Skip to content

Commit

Permalink
test for UTF8 job failure sanitization
Browse files Browse the repository at this point in the history
thanks to @myronmarston
  • Loading branch information
hone committed Jun 28, 2012
1 parent 01af327 commit 598b470
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/resque_failure_redis_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'test_helper'
require 'resque/failure/redis'

context "Resque::Failure::Redis" do
setup do
@bad_string = [39, 250, 141, 168, 138, 191, 52, 211, 159, 86, 93, 95, 39].map { |c| c.chr }.join
exception = StandardError.exception(@bad_string)
worker = Resque::Worker.new(:test)
queue = "queue"
payload = { "class" => Object, "args" => 3 }
@redis_backend = Resque::Failure::Redis.new(exception, worker, queue, payload)
end

test 'cleans up bad strings before saving the failure, in order to prevent errors on the resque UI' do
# test assumption: the bad string should not be able to round trip though JSON
assert_raises(MultiJson::DecodeError) {
MultiJson.decode(MultiJson.encode(@bad_string))
}

@redis_backend.save
Resque::Failure::Redis.all # should not raise an error
end
end

0 comments on commit 598b470

Please sign in to comment.