correct spec failure, only test code was affected
This commit is contained in:
parent
33df000bb7
commit
f432b9f5b7
|
@ -72,6 +72,7 @@ class RandomTopicSelector
|
|||
Category.select(:id).each do |c|
|
||||
$redis.del cache_key(c)
|
||||
end
|
||||
$redis.del cache_key
|
||||
end
|
||||
|
||||
def self.cache_key(category=nil)
|
||||
|
|
|
@ -425,7 +425,7 @@ class TopicQuery
|
|||
max = (count*1.3).to_i
|
||||
ids = RandomTopicSelector.next(max) + RandomTopicSelector.next(max, topic.category)
|
||||
|
||||
result.where(id: ids)
|
||||
result.where(id: ids.uniq)
|
||||
end
|
||||
|
||||
def suggested_ordering(result, options)
|
||||
|
|
|
@ -432,6 +432,10 @@ describe TopicQuery do
|
|||
|
||||
context 'when logged in' do
|
||||
|
||||
before do
|
||||
RandomTopicSelector.clear_cache!
|
||||
end
|
||||
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
let(:suggested_topics) { topic_query.list_suggested_for(topic).topics.map{|t| t.id} }
|
||||
|
||||
|
@ -450,7 +454,6 @@ describe TopicQuery do
|
|||
let!(:fully_read_archived) { Fabricate(:post, user: creator).topic }
|
||||
|
||||
before do
|
||||
RandomTopicSelector.clear_cache!
|
||||
user.auto_track_topics_after_msecs = 0
|
||||
user.save
|
||||
TopicUser.update_last_read(user, partially_read.id, 0, 0)
|
||||
|
@ -463,6 +466,17 @@ describe TopicQuery do
|
|||
fully_read_archived.save
|
||||
end
|
||||
|
||||
|
||||
it "returns unread, then new, then random" do
|
||||
SiteSetting.suggested_topics = 7
|
||||
expect(suggested_topics[0]).to eq(partially_read.id)
|
||||
expect(suggested_topics[1,3]).to include(new_topic.id)
|
||||
expect(suggested_topics[1,3]).to include(closed_topic.id)
|
||||
expect(suggested_topics[1,3]).to include(archived_topic.id)
|
||||
expect(suggested_topics[4]).to eq(fully_read.id)
|
||||
# random doesn't include closed and archived
|
||||
end
|
||||
|
||||
it "won't return new or fully read if there are enough partially read topics" do
|
||||
SiteSetting.suggested_topics = 1
|
||||
expect(suggested_topics).to eq([partially_read.id])
|
||||
|
@ -476,16 +490,6 @@ describe TopicQuery do
|
|||
expect(suggested_topics[1,3]).to include(archived_topic.id)
|
||||
end
|
||||
|
||||
# it "returns unread, then new, then random" do
|
||||
# SiteSetting.suggested_topics = 7
|
||||
# expect(suggested_topics[0]).to eq(partially_read.id)
|
||||
# expect(suggested_topics[1,3]).to include(new_topic.id)
|
||||
# expect(suggested_topics[1,3]).to include(closed_topic.id)
|
||||
# expect(suggested_topics[1,3]).to include(archived_topic.id)
|
||||
# expect(suggested_topics[4]).to eq(fully_read.id)
|
||||
# # random doesn't include closed and archived
|
||||
# end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue