codeclimate-services 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6eec64efaec80eeb0b6c5b285b240567a8ea9b0
|
4
|
+
data.tar.gz: db56869b1abd78be91b81f4d241a42b232ff6e89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6802d6c6dd3c157aff5d73dc2b71d5d9254c6c638044669ce03690261fdddf4bcf724008f406d61eea1a0741e84fae2749c0bde1284f076fcc212ca2078dd3c7
|
7
|
+
data.tar.gz: 97a9f8f65e9c7ace31ecc2f0585fba61cd1de29e071e3afbaf84f943126e2b3331006a2c7bdfe73f3b2c669af38b56c7f80e214288a64a7748a77ebe34a68fa8
|
@@ -9,6 +9,10 @@ class CC::Service::GitHubIssues < CC::Service
|
|
9
9
|
attribute :labels, String,
|
10
10
|
label: "Labels (comma separated)",
|
11
11
|
description: "Comma separated list of labels to apply to the issue"
|
12
|
+
attribute :base_url, String,
|
13
|
+
label: "Github API Base URL",
|
14
|
+
description: "Base URL for the Github API",
|
15
|
+
default: "https://api.github.com"
|
12
16
|
|
13
17
|
validates :oauth_token, presence: true
|
14
18
|
end
|
@@ -17,8 +21,6 @@ class CC::Service::GitHubIssues < CC::Service
|
|
17
21
|
self.description = "Open issues on GitHub"
|
18
22
|
self.issue_tracker = true
|
19
23
|
|
20
|
-
BASE_URL = "https://api.github.com"
|
21
|
-
|
22
24
|
def receive_test
|
23
25
|
result = create_issue("Test ticket from Code Climate", "")
|
24
26
|
result.merge(
|
@@ -66,7 +68,7 @@ private
|
|
66
68
|
http.headers["Authorization"] = "token #{config.oauth_token}"
|
67
69
|
http.headers["User-Agent"] = "Code Climate"
|
68
70
|
|
69
|
-
url = "#{
|
71
|
+
url = "#{config.base_url}/repos/#{config.project}/issues"
|
70
72
|
service_post(url, params.to_json) do |response|
|
71
73
|
body = JSON.parse(response.body)
|
72
74
|
{
|
@@ -11,6 +11,10 @@ class CC::Service::GitHubPullRequests < CC::Service
|
|
11
11
|
attribute :add_comment, Boolean,
|
12
12
|
label: "Add a comment?",
|
13
13
|
description: "Comment on the pull request after analyzing?"
|
14
|
+
attribute :base_url, String,
|
15
|
+
label: "Github API Base URL",
|
16
|
+
description: "Base URL for the Github API",
|
17
|
+
default: "https://api.github.com"
|
14
18
|
|
15
19
|
validates :oauth_token, presence: true
|
16
20
|
end
|
@@ -18,7 +22,6 @@ class CC::Service::GitHubPullRequests < CC::Service
|
|
18
22
|
self.title = "GitHub Pull Requests"
|
19
23
|
self.description = "Update pull requests on GitHub"
|
20
24
|
|
21
|
-
BASE_URL = "https://api.github.com"
|
22
25
|
BODY_REGEX = %r{<b>Code Climate</b> has <a href=".*">analyzed this pull request</a>}
|
23
26
|
COMMENT_BODY = '<img src="https://codeclimate.com/favicon.png" width="20" height="20" /> <b>Code Climate</b> has <a href="%s">analyzed this pull request</a>.'
|
24
27
|
MESSAGES = [
|
@@ -180,15 +183,15 @@ private
|
|
180
183
|
end
|
181
184
|
|
182
185
|
def base_status_url(commit_sha)
|
183
|
-
"#{
|
186
|
+
"#{config.base_url}/repos/#{github_slug}/statuses/#{commit_sha}"
|
184
187
|
end
|
185
188
|
|
186
189
|
def comments_url
|
187
|
-
"#{
|
190
|
+
"#{config.base_url}/repos/#{github_slug}/issues/#{number}/comments"
|
188
191
|
end
|
189
192
|
|
190
193
|
def user_url
|
191
|
-
"#{
|
194
|
+
"#{config.base_url}/user"
|
192
195
|
end
|
193
196
|
|
194
197
|
def github_slug
|
data/lib/cc/services/version.rb
CHANGED
data/test/github_issues_test.rb
CHANGED
@@ -60,6 +60,17 @@ class TestGitHubIssues < CC::Service::TestCase
|
|
60
60
|
assert_equal "Issue <a href='http://foo.bar'>#2</a> created.", response[:message]
|
61
61
|
end
|
62
62
|
|
63
|
+
def test_different_base_url
|
64
|
+
@stubs.post request_url do |env|
|
65
|
+
assert env[:url].to_s == "http://example.com/#{request_url}"
|
66
|
+
[200, {}, '{"number": 2, "html_url": "http://foo.bar"}']
|
67
|
+
end
|
68
|
+
|
69
|
+
response = receive_event({ name: "test" }, base_url: "http://example.com")
|
70
|
+
|
71
|
+
assert_equal "Issue <a href='http://foo.bar'>#2</a> created.", response[:message]
|
72
|
+
end
|
73
|
+
|
63
74
|
private
|
64
75
|
|
65
76
|
def project
|
@@ -86,10 +97,10 @@ class TestGitHubIssues < CC::Service::TestCase
|
|
86
97
|
receive_event(event_data)
|
87
98
|
end
|
88
99
|
|
89
|
-
def receive_event(event_data = nil)
|
100
|
+
def receive_event(event_data = nil, config = {})
|
90
101
|
receive(
|
91
102
|
CC::Service::GitHubIssues,
|
92
|
-
{ oauth_token: "123", project: project },
|
103
|
+
{ oauth_token: "123", project: project }.merge(config),
|
93
104
|
event_data || event(:quality, from: "D", to: "C")
|
94
105
|
)
|
95
106
|
end
|
@@ -244,6 +244,15 @@ class TestGitHubPullRequests < CC::Service::TestCase
|
|
244
244
|
assert_equal({ ok: false, message: "Nothing happened" }, response)
|
245
245
|
end
|
246
246
|
|
247
|
+
def test_different_base_url
|
248
|
+
@stubs.get("/user") do |env|
|
249
|
+
assert env[:url].to_s == "http://example.com/user"
|
250
|
+
[200, { "x-oauth-scopes" => "gist, user, repo" }, ""]
|
251
|
+
end
|
252
|
+
|
253
|
+
assert receive_test({ add_comment: true, base_url: "http://example.com" })[:ok], "Expected test of pull request to be true"
|
254
|
+
end
|
255
|
+
|
247
256
|
private
|
248
257
|
|
249
258
|
def expect_status_update(repo, commit_sha, params)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeclimate-services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Helmkamp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|