Merge pull request #4055 from tgxworld/fix_topic_view_not_working_in_redis_readonly
FIX: Topic view not working when Redis is readonly.
This commit is contained in:
commit
9d24a00f2e
|
@ -47,7 +47,12 @@ class RandomTopicSelector
|
|||
$redis.ltrim(key, count, -1)
|
||||
end
|
||||
|
||||
if !results.is_a?(Array) # Redis is in readonly mode
|
||||
results = $redis.lrange(key, 0, count-1)
|
||||
else
|
||||
results = results[0]
|
||||
end
|
||||
|
||||
results.map!(&:to_i)
|
||||
|
||||
left = count - results.length
|
||||
|
|
|
@ -11,8 +11,15 @@ describe RandomTopicSelector do
|
|||
$redis.rpush key, t
|
||||
end
|
||||
|
||||
expect(RandomTopicSelector.next(0)).to eq([])
|
||||
expect(RandomTopicSelector.next(2)).to eq([0,1])
|
||||
|
||||
$redis.expects(:multi).returns(Discourse.received_readonly!)
|
||||
expect(RandomTopicSelector.next(2)).to eq([2,3])
|
||||
$redis.unstub(:multi)
|
||||
|
||||
expect(RandomTopicSelector.next(2)).to eq([2,3])
|
||||
expect(RandomTopicSelector.next(2)).to eq([])
|
||||
end
|
||||
|
||||
it 'can correctly backfill' do
|
||||
|
|
Loading…
Reference in New Issue