mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Add unit tests for testing if infinity as highest_date works.
This commit is contained in:
parent
2c3bdf48d1
commit
3e5ff66bed
1 changed files with 19 additions and 10 deletions
|
@ -134,12 +134,21 @@ describe TopicQuery do
|
|||
participant_count: 2,
|
||||
bumped_at: 1.minute.ago)
|
||||
end
|
||||
let!(:future_topic) do
|
||||
Fabricate(:topic, title: 'this is a topic in far future',
|
||||
user: creator,
|
||||
views: 30,
|
||||
like_count: 11,
|
||||
posts_count: 6,
|
||||
participant_count: 5,
|
||||
bumped_at: 1000.years.from_now)
|
||||
end
|
||||
|
||||
let(:topics) { topic_query.list_latest.topics }
|
||||
|
||||
context 'list_latest' do
|
||||
it "returns the topics in the correct order" do
|
||||
topics.map(&:id).should == [pinned_topic, closed_topic, archived_topic, regular_topic].map(&:id)
|
||||
topics.map(&:id).should == [pinned_topic, future_topic, closed_topic, archived_topic, regular_topic].map(&:id)
|
||||
|
||||
# includes the invisible topic if you're a moderator
|
||||
TopicQuery.new(moderator).list_latest.topics.include?(invisible_topic).should be_true
|
||||
|
@ -156,28 +165,28 @@ describe TopicQuery do
|
|||
|
||||
it "returns the topics in correct order" do
|
||||
# returns the topics in likes order if requested
|
||||
ids_in_order('posts').should == [pinned_topic, archived_topic, regular_topic, invisible_topic, closed_topic].map(&:id)
|
||||
ids_in_order('posts').should == [pinned_topic, archived_topic, future_topic, regular_topic, invisible_topic, closed_topic].map(&:id)
|
||||
|
||||
# returns the topics in reverse likes order if requested
|
||||
ids_in_order('posts', false).should == [closed_topic, invisible_topic, regular_topic, archived_topic, pinned_topic].map(&:id)
|
||||
ids_in_order('posts', false).should == [closed_topic, invisible_topic, regular_topic, future_topic, archived_topic, pinned_topic].map(&:id)
|
||||
|
||||
# returns the topics in likes order if requested
|
||||
ids_in_order('likes').should == [pinned_topic, regular_topic, archived_topic, invisible_topic, closed_topic].map(&:id)
|
||||
ids_in_order('likes').should == [pinned_topic, regular_topic, archived_topic, future_topic, invisible_topic, closed_topic].map(&:id)
|
||||
|
||||
# returns the topics in reverse likes order if requested
|
||||
ids_in_order('likes', false).should == [closed_topic, invisible_topic, archived_topic, regular_topic, pinned_topic].map(&:id)
|
||||
ids_in_order('likes', false).should == [closed_topic, invisible_topic, future_topic, archived_topic, regular_topic, pinned_topic].map(&:id)
|
||||
|
||||
# returns the topics in views order if requested
|
||||
ids_in_order('views').should == [regular_topic, archived_topic, pinned_topic, closed_topic, invisible_topic].map(&:id)
|
||||
ids_in_order('views').should == [regular_topic, archived_topic, future_topic, pinned_topic, closed_topic, invisible_topic].map(&:id)
|
||||
|
||||
# returns the topics in reverse views order if requested" do
|
||||
ids_in_order('views', false).should == [invisible_topic, closed_topic, pinned_topic, archived_topic, regular_topic].map(&:id)
|
||||
ids_in_order('views', false).should == [invisible_topic, closed_topic, pinned_topic, future_topic, archived_topic, regular_topic].map(&:id)
|
||||
|
||||
# returns the topics in posters order if requested" do
|
||||
ids_in_order('posters').should == [pinned_topic, regular_topic, invisible_topic, closed_topic, archived_topic].map(&:id)
|
||||
ids_in_order('posters').should == [pinned_topic, regular_topic, future_topic, invisible_topic, closed_topic, archived_topic].map(&:id)
|
||||
|
||||
# returns the topics in reverse posters order if requested" do
|
||||
ids_in_order('posters', false).should == [archived_topic, closed_topic, invisible_topic, regular_topic, pinned_topic].map(&:id)
|
||||
ids_in_order('posters', false).should == [archived_topic, closed_topic, invisible_topic, future_topic, regular_topic, pinned_topic].map(&:id)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -191,7 +200,7 @@ describe TopicQuery do
|
|||
end
|
||||
|
||||
it "no longer shows the pinned topic at the top" do
|
||||
topics.should == [closed_topic, archived_topic, pinned_topic, regular_topic]
|
||||
topics.should == [future_topic, closed_topic, archived_topic, pinned_topic, regular_topic]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue