From f8e1fc70a1c0c58633da7ba6ff722d97551ab442 Mon Sep 17 00:00:00 2001 From: Daniel Baena Date: Fri, 11 Dec 2015 21:06:27 +0100 Subject: [PATCH] #670 --- lib/score_calculator.rb | 2 +- spec/models/comment_spec.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/score_calculator.rb b/lib/score_calculator.rb index 5e606f5ae..70d3835ec 100644 --- a/lib/score_calculator.rb +++ b/lib/score_calculator.rb @@ -17,7 +17,7 @@ module ScoreCalculator end def self.confidence_score(votes_total, votes_up) - return 0 unless votes_total > 0 + return 1 unless votes_total > 0 votes_total = votes_total.to_f votes_up = votes_up.to_f diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 11a02400a..b2696381e 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -56,6 +56,9 @@ describe Comment do comment = create(:comment, :with_confidence_score, cached_votes_up: 10, cached_votes_total: 100) expect(comment.confidence_score).to eq(-800) + + comment = create(:comment, :with_confidence_score, cached_votes_up: 0, cached_votes_total: 0) + expect(comment.confidence_score).to eq(1) end describe 'actions which affect it' do