Commit a4fefc0c4a63790396763843b65ecee84e5e88d9
Exists in
staging
and in
42 other branches
Merge branch 'stable'
Showing
2 changed files
with
9 additions
and
1 deletions
Show diff stats
app/helpers/content_viewer_helper.rb
| ... | ... | @@ -10,7 +10,7 @@ module ContentViewerHelper |
| 10 | 10 | end |
| 11 | 11 | |
| 12 | 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 | 14 | end |
| 15 | 15 | |
| 16 | 16 | def article_title(article, args = {}) | ... | ... |
test/unit/content_viewer_helper_test.rb
| ... | ... | @@ -83,6 +83,14 @@ class ContentViewerHelperTest < ActionView::TestCase |
| 83 | 83 | assert_equal '', result |
| 84 | 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 | 94 | should 'not list feed article' do |
| 87 | 95 | profile.articles << build(Blog, :name => 'Blog test', :profile => profile) |
| 88 | 96 | assert_includes profile.blog.children.map{|i| i.class}, RssFeed | ... | ... |