remove #next_post_path and #previous_post_path from postpresenter

This commit is contained in:
Fabian Rodriguez 2013-12-01 16:54:05 -02:00
parent 92db8cb929
commit d7b8cb2997
2 changed files with 6 additions and 27 deletions

View file

@ -35,8 +35,6 @@ class PostPresenter
:frame_name => @post.frame_name || template_name, :frame_name => @post.frame_name || template_name,
:root => root, :root => root,
:title => title, :title => title,
:next_post => next_post_path,
:previous_post => previous_post_path,
:address => @post.address, :address => @post.address,
:interactions => { :interactions => {
@ -49,14 +47,6 @@ class PostPresenter
} }
end end
def next_post_path
Rails.application.routes.url_helpers.next_post_path(@post)
end
def previous_post_path
Rails.application.routes.url_helpers.previous_post_path(@post)
end
def title def title
@post.text.present? ? post_page_title(@post) : I18n.translate('posts.presenter.title', :name => @post.author_name) @post.text.present? ? post_page_title(@post) : I18n.translate('posts.presenter.title', :name => @post.author_name)
end end

View file

@ -42,18 +42,18 @@ describe PostPresenter do
@unauthenticated_presenter.user_reshare.should be_nil @unauthenticated_presenter.user_reshare.should be_nil
end end
end end
describe '#root' do describe '#root' do
it 'does not raise if the absolute_root does not exists' do it 'does not raise if the absolute_root does not exists' do
first_reshare = FactoryGirl.create :reshare first_reshare = FactoryGirl.create :reshare
first_reshare.root = nil first_reshare.root = nil
reshare = FactoryGirl.create :reshare, :root => first_reshare reshare = FactoryGirl.create :reshare, :root => first_reshare
expect { expect {
PostPresenter.new(reshare).root PostPresenter.new(reshare).root
}.to_not raise_error }.to_not raise_error
end end
it 'does not raise if the root does not exists' do it 'does not raise if the root does not exists' do
reshare = FactoryGirl.create:reshare reshare = FactoryGirl.create:reshare
reshare.root = nil reshare.root = nil
@ -62,20 +62,8 @@ describe PostPresenter do
}.to_not raise_error }.to_not raise_error
end end
end end
describe '#next_post_path' do
it 'returns a string of the users next post' do
@presenter.next_post_path.should == "#{Rails.application.routes.url_helpers.post_path(@sm)}/next"
end
end
describe '#previous_post_path' do describe '#title' do
it 'returns a string of the users next post' do
@presenter.previous_post_path.should == "#{Rails.application.routes.url_helpers.post_path(@sm)}/previous"
end
end
describe '#title' do
context 'with posts with text' do context 'with posts with text' do
context 'with a Markdown header of less than 200 characters on first line'do context 'with a Markdown header of less than 200 characters on first line'do
it 'returns atx style header' do it 'returns atx style header' do
@ -90,6 +78,7 @@ describe PostPresenter do
@presenter.title.should == "My title \n======" @presenter.title.should == "My title \n======"
end end
end end
context 'without a Markdown header of less than 200 characters on first line 'do context 'without a Markdown header of less than 200 characters on first line 'do
it 'truncates post to the 20 first characters' do it 'truncates post to the 20 first characters' do
@sm = stub(:text => "Very, very, very long post") @sm = stub(:text => "Very, very, very long post")
@ -98,9 +87,9 @@ describe PostPresenter do
end end
end end
end end
context 'with posts without text' do context 'with posts without text' do
it ' displays a messaage with the post class' do it ' displays a messaage with the post class' do
@sm = stub(:text => "", :author => bob.person, :author_name => bob.person.name) @sm = stub(:text => "", :author => bob.person, :author_name => bob.person.name)
@presenter.post = @sm @presenter.post = @sm
@presenter.title.should == "A post from #{@sm.author.name}" @presenter.title.should == "A post from #{@sm.author.name}"