Commit a4fefc0c4a63790396763843b65ecee84e5e88d9

Authored by Daniela Feitosa
2 parents b1fb1825 6c59ac4a

Merge branch 'stable'

app/helpers/content_viewer_helper.rb
@@ -10,7 +10,7 @@ module ContentViewerHelper @@ -10,7 +10,7 @@ module ContentViewerHelper
10 end 10 end
11 11
12 def number_of_comments(article) 12 def number_of_comments(article)
13 - display_number_of_comments(article.comments_count - article.spam_comments_count) 13 + display_number_of_comments(article.comments_count - article.spam_comments_count.to_i)
14 end 14 end
15 15
16 def article_title(article, args = {}) 16 def article_title(article, args = {})
test/unit/content_viewer_helper_test.rb
@@ -83,6 +83,14 @@ class ContentViewerHelperTest < ActionView::TestCase @@ -83,6 +83,14 @@ class ContentViewerHelperTest < ActionView::TestCase
83 assert_equal '', result 83 assert_equal '', result
84 end 84 end
85 85
  86 + should 'not crash if spam_comments_count is nil' do
  87 + article = TextileArticle.new(:name => 'post for test', :body => 'post for test', :profile => profile)
  88 + article.stubs(:comments_count).returns(10)
  89 + article.stubs(:spam_comments_count).returns(nil)
  90 + result = number_of_comments(article)
  91 + assert_match /10 comments/, result
  92 + end
  93 +
86 should 'not list feed article' do 94 should 'not list feed article' do
87 profile.articles << build(Blog, :name => 'Blog test', :profile => profile) 95 profile.articles << build(Blog, :name => 'Blog test', :profile => profile)
88 assert_includes profile.blog.children.map{|i| i.class}, RssFeed 96 assert_includes profile.blog.children.map{|i| i.class}, RssFeed