Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 55828fb

Browse files
committed
Merge pull request #70 from codeclimate/gd-remove-status-rollout
Remove rollout call for quality stats
2 parents 423b4ea + 7a2610c commit 55828fb

File tree

3 files changed

+19
-34
lines changed

3 files changed

+19
-34
lines changed

lib/cc/presenters/github_pull_requests_presenter.rb

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@ def initialize(payload, repo_config)
1313
end
1414

1515
def success_message
16-
if @repo_config.pr_status_quality_stats?
17-
if both_issue_counts_zero?
18-
"Code Climate didn't find any new or fixed issues."
19-
else
20-
"Code Climate found #{formatted_issue_counts}."
21-
end
16+
if both_issue_counts_zero?
17+
"Code Climate didn't find any new or fixed issues."
2218
else
23-
"Code Climate has analyzed this pull request."
19+
"Code Climate found #{formatted_issue_counts}."
2420
end
2521
end
2622

@@ -53,10 +49,6 @@ def formatted_issue_counts
5349
def issue_counts
5450
[@new_count, @fixed_count]
5551
end
56-
57-
def issue_counts_in_payload?
58-
issue_counts.all?
59-
end
6052
end
6153
end
6254
end

test/github_pull_requests_test.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,15 @@ def test_pull_request_status_pending
1717
def test_pull_request_status_success_detailed
1818
expect_status_update("pbrisbin/foo", "abc123", {
1919
"state" => "success",
20-
"description" => "Code Climate found 1 new issue and 2 fixed issues.",
20+
"description" => "Code Climate found 2 new issues and 1 fixed issue.",
2121
})
2222

2323
receive_pull_request(
2424
{ update_status: true },
2525
{
2626
github_slug: "pbrisbin/foo",
2727
commit_sha: "abc123",
28-
state: "success",
29-
issue_comparison_counts: {
30-
"fixed" => 2,
31-
"new" => 1,
32-
}
28+
state: "success"
3329
},
3430
true
3531
)
@@ -38,7 +34,7 @@ def test_pull_request_status_success_detailed
3834
def test_pull_request_status_success_generic
3935
expect_status_update("pbrisbin/foo", "abc123", {
4036
"state" => "success",
41-
"description" => /has analyzed/,
37+
"description" => /found 2 new issues and 1 fixed issue/,
4238
})
4339

4440
receive_pull_request({ update_status: true }, {
@@ -179,6 +175,10 @@ def test_pull_request_comment
179175
number: 1,
180176
state: "success",
181177
compare_url: "http://example.com",
178+
issue_comparison_counts: {
179+
"fixed" => 2,
180+
"new" => 1,
181+
}
182182
})
183183
end
184184

@@ -248,7 +248,7 @@ def receive_pull_request(config, event_data, truthy_repo_config = false)
248248
receive(
249249
CC::Service::GitHubPullRequests,
250250
{ oauth_token: "123" }.merge(config),
251-
{ name: "pull_request" }.merge(event_data),
251+
{ name: "pull_request", issue_comparison_counts: {'fixed' => 1, 'new' => 2} }.merge(event_data),
252252
truthy_repo_config ? TruthyRepoConfig.new : FalsyRepoConfig.new
253253
)
254254
end
@@ -257,7 +257,7 @@ def receive_test(config, event_data = {})
257257
receive(
258258
CC::Service::GitHubPullRequests,
259259
{ oauth_token: "123" }.merge(config),
260-
{ name: "test" }.merge(event_data)
260+
{ name: "test", issue_comparison_counts: {'fixed' => 1, 'new' => 2} }.merge(event_data)
261261
)
262262
end
263263
end

test/presenters/github_pull_requests_presenter_test.rb

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,38 @@
22
require "cc/presenters/github_pull_requests_presenter"
33

44
class TestGitHubPullRequestsPresenter < CC::Service::TestCase
5-
def test_message_quality_stats_not_enabled
6-
assert_equal(
7-
"Code Climate has analyzed this pull request.",
8-
build_presenter(false, "fixed" => 1, "new" => 1).success_message
9-
)
10-
end
11-
125
def test_message_singular
136
assert_equal(
147
"Code Climate found 1 new issue and 1 fixed issue.",
15-
build_presenter(true, "fixed" => 1, "new" => 1).success_message
8+
build_presenter("fixed" => 1, "new" => 1).success_message
169
)
1710
end
1811

1912
def test_message_plural
2013
assert_equal(
2114
"Code Climate found 2 new issues and 1 fixed issue.",
22-
build_presenter(true, "fixed" => 1, "new" => 2).success_message
15+
build_presenter("fixed" => 1, "new" => 2).success_message
2316
)
2417
end
2518

2619
def test_message_only_fixed
2720
assert_equal(
2821
"Code Climate found 1 fixed issue.",
29-
build_presenter(true, "fixed" => 1, "new" => 0).success_message
22+
build_presenter("fixed" => 1, "new" => 0).success_message
3023
)
3124
end
3225

3326
def test_message_only_new
3427
assert_equal(
3528
"Code Climate found 3 new issues.",
36-
build_presenter(true, "fixed" => 0, "new" => 3).success_message
29+
build_presenter("fixed" => 0, "new" => 3).success_message
3730
)
3831
end
3932

4033
def test_message_no_new_or_fixed
4134
assert_equal(
4235
"Code Climate didn't find any new or fixed issues.",
43-
build_presenter(true, "fixed" => 0, "new" => 0).success_message
36+
build_presenter("fixed" => 0, "new" => 0).success_message
4437
)
4538
end
4639

@@ -50,10 +43,10 @@ def build_payload(issue_counts)
5043
{ "issue_comparison_counts" => issue_counts }
5144
end
5245

53-
def build_presenter(quality_stats_enabled, issue_counts)
46+
def build_presenter(issue_counts)
5447
CC::Service::GitHubPullRequestsPresenter.new(
5548
build_payload(issue_counts),
56-
OpenStruct.new(pr_status_quality_stats?: quality_stats_enabled)
49+
OpenStruct.new
5750
)
5851
end
5952
end

0 commit comments

Comments
 (0)