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

Commit 4474f6e

Browse files
committed
Merge pull request #71 from codeclimate/gd-destroy-repo-config
Remove repo configs
2 parents 55828fb + e94945a commit 4474f6e

File tree

8 files changed

+13
-40
lines changed

8 files changed

+13
-40
lines changed

lib/cc/presenters/github_pull_requests_presenter.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
module CC
22
class Service
33
class GitHubPullRequestsPresenter
4-
def initialize(payload, repo_config)
4+
def initialize(payload)
55
issue_comparison_counts = payload["issue_comparison_counts"]
66

77
if issue_comparison_counts
88
@fixed_count = issue_comparison_counts["fixed"]
99
@new_count = issue_comparison_counts["new"]
1010
end
11-
12-
@repo_config = repo_config
1311
end
1412

1513
def success_message

lib/cc/service.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,10 @@ def self.slug
6969
end
7070
end
7171

72-
def initialize(config, payload, repo_config)
72+
def initialize(config, payload)
7373
@payload = payload.stringify_keys
7474
@config = create_config(config)
7575
@event = @payload["name"].to_s
76-
@repo_config = repo_config
7776

7877
load_helper
7978
validate_event

lib/cc/services/github_pull_requests.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def update_status_success
7676
end
7777

7878
def presenter
79-
CC::Service::GitHubPullRequestsPresenter.new(@payload, @repo_config)
79+
CC::Service::GitHubPullRequestsPresenter.new(@payload)
8080
end
8181

8282
def update_status_error

service_test.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ def call
3131
end
3232
end
3333

34-
class FalsyRepoConfig
35-
def method_missing(*args)
36-
false
37-
end
38-
end
39-
4034
class ServiceTest
4135
def initialize(klass, *params)
4236
@klass = klass
@@ -76,8 +70,7 @@ def test_service(klass, config, payload)
7670

7771
service = klass.new(
7872
config,
79-
{ name: :test, repo_name: repo_name }.merge(payload),
80-
FalsyRepoConfig.new
73+
{ name: :test, repo_name: repo_name }.merge(payload)
8174
)
8275

8376
CC::Service::Invocation.new(service) do |i|

test/github_pull_requests_test.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ def test_pull_request_status_success_detailed
2626
github_slug: "pbrisbin/foo",
2727
commit_sha: "abc123",
2828
state: "success"
29-
},
30-
true
29+
}
3130
)
3231
end
3332

@@ -244,12 +243,11 @@ def expect_comment(repo, number, content)
244243
end
245244
end
246245

247-
def receive_pull_request(config, event_data, truthy_repo_config = false)
246+
def receive_pull_request(config, event_data)
248247
receive(
249248
CC::Service::GitHubPullRequests,
250249
{ oauth_token: "123" }.merge(config),
251-
{ name: "pull_request", issue_comparison_counts: {'fixed' => 1, 'new' => 2} }.merge(event_data),
252-
truthy_repo_config ? TruthyRepoConfig.new : FalsyRepoConfig.new
250+
{ name: "pull_request", issue_comparison_counts: {'fixed' => 1, 'new' => 2} }.merge(event_data)
253251
)
254252
end
255253

test/helper.rb

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def teardown
2525
@stubs.verify_stubbed_calls
2626
end
2727

28-
def service(klass, data, payload, repo_config = FalsyRepoConfig.new)
29-
service = klass.new(data, payload, repo_config)
28+
def service(klass, data, payload)
29+
service = klass.new(data, payload)
3030
service.http :adapter => [:test, @stubs]
3131
service
3232
end
@@ -47,16 +47,4 @@ def stub_http(url, response = nil, &block)
4747
block ||= lambda{|*args| response }
4848
@stubs.post(url, &block)
4949
end
50-
51-
class FalsyRepoConfig
52-
def method_missing(*args)
53-
false
54-
end
55-
end
56-
57-
class TruthyRepoConfig
58-
def method_missing(*args)
59-
true
60-
end
61-
end
6250
end

test/presenters/github_pull_requests_presenter_test.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ def build_payload(issue_counts)
4444
end
4545

4646
def build_presenter(issue_counts)
47-
CC::Service::GitHubPullRequestsPresenter.new(
48-
build_payload(issue_counts),
49-
OpenStruct.new
50-
)
47+
CC::Service::GitHubPullRequestsPresenter.new(build_payload(issue_counts))
5148
end
5249
end

test/service_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ def test_validates_events
88
end
99

1010
def test_default_path_to_ca_file
11-
s = CC::Service.new({}, {name: "test"}, FalsyRepoConfig.new)
11+
s = CC::Service.new({}, {name: "test"})
1212
assert_equal(File.expand_path("../../config/cacert.pem", __FILE__), s.ca_file)
1313
assert File.exist?(s.ca_file)
1414
end
1515

1616
def test_custom_path_to_ca_file
1717
ENV["CODECLIMATE_CA_FILE"] = "/tmp/cacert.pem"
18-
s = CC::Service.new({}, {name: "test"}, FalsyRepoConfig.new)
18+
s = CC::Service.new({}, {name: "test"})
1919
assert_equal("/tmp/cacert.pem", s.ca_file)
2020
ensure
2121
ENV.delete("CODECLIMATE_CA_FILE")
2222
end
2323

2424
def test_nothing_has_a_handler
25-
service = CC::Service.new({}, {name: "test"}, FalsyRepoConfig.new)
25+
service = CC::Service.new({}, {name: "test"})
2626

2727
result = service.receive
2828

0 commit comments

Comments
 (0)