lib/cc/presenters/pull_requests_presenter.rb in codeclimate-services-1.3.0 vs lib/cc/presenters/pull_requests_presenter.rb in codeclimate-services-1.4.0
- old
+ new
@@ -10,10 +10,11 @@
@fixed_count = issue_comparison_counts["fixed"]
@new_count = issue_comparison_counts["new"]
end
@covered_percent = payload["covered_percent"]
+ @covered_percent_delta = payload["covered_percent_delta"]
end
def error_message
"Code Climate encountered an error attempting to analyze this pull request."
end
@@ -24,12 +25,20 @@
def skipped_message
"Code Climate has skipped analysis of this commit."
end
- def coverage_success_message
- "Test coverage for this commit: #{@covered_percent}%"
+ def coverage_message
+ message = "#{formatted_percent(@covered_percent)}% test coverage"
+
+ if @covered_percent_delta.positive?
+ message += " (+#{formatted_percent(@covered_percent_delta)}%)"
+ elsif @covered_percent_delta.negative?
+ message += " (#{formatted_percent(@covered_percent_delta)}%)"
+ end
+
+ message
end
def success_message
if both_issue_counts_zero?
"Code Climate didn't find any new or fixed issues."
@@ -60,9 +69,13 @@
end
end
def formatted_issue_counts
[formatted_new_issues, formatted_fixed_issues].compact.to_sentence
+ end
+
+ def formatted_percent(value)
+ "%g" % ("%.2f" % value)
end
def issue_counts
[@new_count, @fixed_count]
end