diff --git a/lib/discourse_redis.rb b/lib/discourse_redis.rb index 341f3d131c5..1ed8fc6a5ed 100644 --- a/lib/discourse_redis.rb +++ b/lib/discourse_redis.rb @@ -39,7 +39,7 @@ class DiscourseRedis # prefix the key with the namespace def method_missing(meth, *args, **kwargs, &block) if @redis.respond_to?(meth) - DiscourseRedis.ignore_readonly { @redis.public_send(meth, *args, &block) } + DiscourseRedis.ignore_readonly { @redis.public_send(meth, *args, **kwargs, &block) } else super end diff --git a/spec/components/discourse_redis_spec.rb b/spec/components/discourse_redis_spec.rb index 8156a573ec2..aa8684d1b9a 100644 --- a/spec/components/discourse_redis_spec.rb +++ b/spec/components/discourse_redis_spec.rb @@ -78,5 +78,58 @@ describe DiscourseRedis do expect(Discourse.recently_readonly?).to eq(true) end end + + describe "#eval" do + it "keys and arvg are passed correcty" do + keys = ["key1", "key2"] + argv = ["arg1", "arg2"] + + expect(Discourse.redis.eval( + "return { KEYS, ARGV };", + keys: keys, + argv: argv, + )).to eq([keys, argv]) + + expect(Discourse.redis.eval( + "return { KEYS, ARGV };", + keys, + argv: argv, + )).to eq([keys, argv]) + + expect(Discourse.redis.eval( + "return { KEYS, ARGV };", + keys, + argv, + )).to eq([keys, argv]) + end + end + + describe "#evalsha" do + it "keys and arvg are passed correcty" do + keys = ["key1", "key2"] + argv = ["arg1", "arg2"] + + script = "return { KEYS, ARGV };" + Discourse.redis.script(:load, script) + sha = Digest::SHA1.hexdigest(script) + expect(Discourse.redis.evalsha( + sha, + keys: keys, + argv: argv, + )).to eq([keys, argv]) + + expect(Discourse.redis.evalsha( + sha, + keys, + argv: argv, + )).to eq([keys, argv]) + + expect(Discourse.redis.evalsha( + sha, + keys, + argv, + )).to eq([keys, argv]) + end + end end end