Skip to content

Commit

Permalink
Merge pull request #1 from challengee/lock-argument-fix
Browse files Browse the repository at this point in the history
Lock argument fix
  • Loading branch information
bruno authored Feb 7, 2018
2 parents d364a7e + bc2c756 commit db0dc7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/resque/plugins/lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def lock_timeout
# passed the same arguments as `perform`, that is, your job's
# payload.
def lock(*args)
"lock:#{name}-#{args.to_s}"
"lock:#{name}-#{Resque.encode(args)}"
end

# See the documentation for SETNX http://redis.io/commands/setnx for an
Expand Down
8 changes: 8 additions & 0 deletions test/lock_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ def test_lock
assert_equal 1, Resque.redis.llen('queue:lock_test')
end

def test_lock_arguments
client_arguments = :test
client_lock = Job.lock(client_arguments)
job_arguments = Resque.decode(Resque.encode(client_arguments))
job_lock = Job.lock(job_arguments)
assert_equal client_lock, job_lock
end

def test_deadlock
now = Time.now.to_i

Expand Down

0 comments on commit db0dc7a

Please sign in to comment.