mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
We never want to filter TopicView to just one post.
This commit is contained in:
parent
69c7b5aeed
commit
27a07054d7
2 changed files with 16 additions and 30 deletions
|
@ -3,7 +3,7 @@ require_dependency 'topic_query'
|
|||
|
||||
class TopicView
|
||||
|
||||
attr_accessor :topic, :min, :max, :draft, :draft_key, :draft_sequence
|
||||
attr_accessor :topic, :min, :max, :draft, :draft_key, :draft_sequence, :posts
|
||||
|
||||
def initialize(topic_id, user=nil, options={})
|
||||
@topic = find_topic(topic_id)
|
||||
|
@ -127,15 +127,6 @@ class TopicView
|
|||
@max = @min + @posts.size
|
||||
end
|
||||
|
||||
def posts
|
||||
@post_number.present? ? find_post_by_post_number : @posts
|
||||
end
|
||||
|
||||
def find_post_by_post_number
|
||||
@posts.select {|post| post.post_number == @post_number.to_i }
|
||||
end
|
||||
|
||||
|
||||
def read?(post_number)
|
||||
read_posts_set.include?(post_number)
|
||||
end
|
||||
|
|
|
@ -167,29 +167,24 @@ describe TopicView do
|
|||
context '.posts' do
|
||||
context 'near a post_number' do
|
||||
|
||||
context 'with a valid post_number' do
|
||||
before do
|
||||
topic.reload
|
||||
topic_view.filter_posts_near(p2.post_number)
|
||||
end
|
||||
let (:near_topic_view) { TopicView.new(topic.id, coding_horror, post_number: p2.post_number) }
|
||||
|
||||
it 'returns posts around a post number' do
|
||||
topic_view.posts.should == [p1, p2, p3]
|
||||
end
|
||||
|
||||
it 'has a min of the 1st post number' do
|
||||
topic_view.min.should == p1.post_number
|
||||
end
|
||||
|
||||
it 'has a max of the 3rd post number' do
|
||||
topic_view.max.should == p3.post_number
|
||||
end
|
||||
|
||||
it 'is the inital load' do
|
||||
topic_view.should be_initial_load
|
||||
end
|
||||
it 'returns posts around a post number' do
|
||||
near_topic_view.posts.should == [p1, p2, p3]
|
||||
end
|
||||
|
||||
it 'has a min of the 1st post number' do
|
||||
near_topic_view.min.should == p1.post_number
|
||||
end
|
||||
|
||||
it 'has a max of the 3rd post number' do
|
||||
near_topic_view.max.should == p3.post_number
|
||||
end
|
||||
|
||||
it 'is the inital load' do
|
||||
near_topic_view.should be_initial_load
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'before a post_number' do
|
||||
|
|
Loading…
Reference in a new issue