Force summary mode when user enters at the top of megalodoon topics.

This commit is contained in:
Guo Xiang Tan
2018-06-21 15:18:52 +08:00
parent f7d22bad90
commit 9a7a079f4d
4 changed files with 35 additions and 21 deletions

View File

@@ -365,22 +365,31 @@ describe TopicView do
end
describe 'when a megalodon topic is closed' do
before do
@original_const = TopicView::MEGA_TOPIC_POSTS_COUNT
TopicView.send(:remove_const, "MEGA_TOPIC_POSTS_COUNT")
TopicView.const_set("MEGA_TOPIC_POSTS_COUNT", 1)
topic.update!(closed: true)
SiteSetting.summary_max_results = 2
end
after do
TopicView.send(:remove_const, "MEGA_TOPIC_POSTS_COUNT")
TopicView.const_set("MEGA_TOPIC_POSTS_COUNT", @original_const)
end
it 'should be forced into summary mode without gaps' do
begin
original_const = TopicView::MEGA_TOPIC_POSTS_COUNT
TopicView.send(:remove_const, "MEGA_TOPIC_POSTS_COUNT")
TopicView.const_set("MEGA_TOPIC_POSTS_COUNT", 1)
SiteSetting.summary_max_results = 2
topic.update!(closed: true)
topic_view = TopicView.new(topic.id, evil_trout, post_number: 1)
topic_view = TopicView.new(topic.id, evil_trout)
expect(topic_view.contains_gaps?).to eq(false)
expect(topic_view.posts).to eq([p5])
end
expect(topic_view.contains_gaps?).to eq(false)
expect(topic_view.posts).to eq([p5])
ensure
TopicView.send(:remove_const, "MEGA_TOPIC_POSTS_COUNT")
TopicView.const_set("MEGA_TOPIC_POSTS_COUNT", original_const)
end
it 'should not be forced into summary mode if post_number is not blank' do
topic_view = TopicView.new(topic.id, evil_trout, post_number: 2)
expect(topic_view.contains_gaps?).to eq(false)
expect(topic_view.posts).to eq([p1, p2, p3])
end
end