diff --git a/app/helpers/reshares_helper.rb b/app/helpers/reshares_helper.rb index c9fb283e6..5b97adc39 100644 --- a/app/helpers/reshares_helper.rb +++ b/app/helpers/reshares_helper.rb @@ -9,6 +9,7 @@ module ResharesHelper def reshare_link(post) if reshare?(post) + return unless post.root link_to t("reshares.reshare.reshare_original"), reshares_path(:root_guid => post.root.guid), :method => :post, diff --git a/spec/helpers/reshares_helper_spec.rb b/spec/helpers/reshares_helper_spec.rb index 524a2bd0c..af5bac1e1 100644 --- a/spec/helpers/reshares_helper_spec.rb +++ b/spec/helpers/reshares_helper_spec.rb @@ -11,5 +11,14 @@ require 'spec_helper' # end # end describe ResharesHelper do - pending "add some examples to (or delete) #{__FILE__}" + include StreamHelper + + describe 'reshare_link' do + it 'does not display a reshare for a post that does not exist' do + reshare = Factory.build(:reshare, :root => nil) + lambda { + reshare_link(reshare) + }.should_not raise_error + end + end end