mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Merge pull request #2644 from xfix/y3k
Year 3000 problem while displaying thread pins.
This commit is contained in:
commit
c74550fbad
2 changed files with 20 additions and 11 deletions
|
@ -12,7 +12,7 @@ module TopicQuerySQL
|
|||
end
|
||||
|
||||
def highest_date
|
||||
"3000-01-01"
|
||||
"infinity"
|
||||
end
|
||||
|
||||
def order_by_category_sql(dir)
|
||||
|
|
|
@ -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 == [future_topic, pinned_topic, archived_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, archived_topic, pinned_topic, future_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