From 27a07054d71000ff7968db8aeafe44ff580676b2 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 12 Feb 2013 19:02:16 -0500 Subject: [PATCH] We never want to filter TopicView to just one post. --- lib/topic_view.rb | 11 +--------- spec/components/topic_view_spec.rb | 35 +++++++++++++----------------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/lib/topic_view.rb b/lib/topic_view.rb index 03d563969e6..e5ad0f5fdcc 100644 --- a/lib/topic_view.rb +++ b/lib/topic_view.rb @@ -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 diff --git a/spec/components/topic_view_spec.rb b/spec/components/topic_view_spec.rb index b4614256116..ef6814330ab 100644 --- a/spec/components/topic_view_spec.rb +++ b/spec/components/topic_view_spec.rb @@ -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