DEV: uses Discourse.redis instead of $redis
This commit is contained in:
parent
05d4338a12
commit
6540d8b957
|
@ -7,7 +7,7 @@ class DiscourseChat::PublicController < ApplicationController
|
|||
params.require(:secret)
|
||||
|
||||
redis_key = "chat_integration:transcript:#{params[:secret]}"
|
||||
content = $redis.get(redis_key)
|
||||
content = Discourse.redis.get(redis_key)
|
||||
|
||||
if content
|
||||
render json: { content: content }
|
||||
|
|
|
@ -192,7 +192,7 @@ module DiscourseChat
|
|||
def self.save_transcript(transcript)
|
||||
secret = SecureRandom.hex
|
||||
redis_key = "chat_integration:transcript:#{secret}"
|
||||
$redis.setex(redis_key, 3600, transcript)
|
||||
Discourse.redis.setex(redis_key, 3600, transcript)
|
||||
secret
|
||||
end
|
||||
|
||||
|
|
|
@ -311,13 +311,13 @@ RSpec.describe DiscourseChat::Manager do
|
|||
it 'saves a transcript to redis' do
|
||||
key = DiscourseChat::Helper.save_transcript("Some content here")
|
||||
|
||||
expect($redis.get("chat_integration:transcript:#{key}")).to eq("Some content here")
|
||||
expect(Discourse.redis.get("chat_integration:transcript:#{key}")).to eq("Some content here")
|
||||
|
||||
ttl = $redis.pttl("chat_integration:transcript:#{key}")
|
||||
ttl = Discourse.redis.pttl("chat_integration:transcript:#{key}")
|
||||
|
||||
# Slight hack since freeze_time doens't work on redis
|
||||
expect($redis.pttl("chat_integration:transcript:#{key}")).to be <= (3601 * 1000)
|
||||
expect($redis.pttl("chat_integration:transcript:#{key}")).to be >= (3599 * 1000)
|
||||
expect(Discourse.redis.pttl("chat_integration:transcript:#{key}")).to be <= (3601 * 1000)
|
||||
expect(Discourse.redis.pttl("chat_integration:transcript:#{key}")).to be >= (3599 * 1000)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue