Skip to content

Commit 598b470

Browse files
committed
test for UTF8 job failure sanitization
thanks to @myronmarston
1 parent 01af327 commit 598b470

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/resque_failure_redis_test.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require 'test_helper'
2+
require 'resque/failure/redis'
3+
4+
context "Resque::Failure::Redis" do
5+
setup do
6+
@bad_string = [39, 250, 141, 168, 138, 191, 52, 211, 159, 86, 93, 95, 39].map { |c| c.chr }.join
7+
exception = StandardError.exception(@bad_string)
8+
worker = Resque::Worker.new(:test)
9+
queue = "queue"
10+
payload = { "class" => Object, "args" => 3 }
11+
@redis_backend = Resque::Failure::Redis.new(exception, worker, queue, payload)
12+
end
13+
14+
test 'cleans up bad strings before saving the failure, in order to prevent errors on the resque UI' do
15+
# test assumption: the bad string should not be able to round trip though JSON
16+
assert_raises(MultiJson::DecodeError) {
17+
MultiJson.decode(MultiJson.encode(@bad_string))
18+
}
19+
20+
@redis_backend.save
21+
Resque::Failure::Redis.all # should not raise an error
22+
end
23+
end

0 commit comments

Comments
 (0)