danger-jira_sync 0.0.4 → 0.0.5
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/jira_sync/gem_version.rb +1 -1
- data/lib/jira_sync/plugin.rb +1 -1
- data/spec/jira_sync_spec.rb +17 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3676486d775890e8168b4c19fcb0723753c638abc1bbf234c305a389fcc74ac3
|
4
|
+
data.tar.gz: 29a78685c72621bc10e6100a9606e9c674e8d7e6e3858a23f77078e4f049f18c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5779baee09ceb623ccd21a4adf03b4621f4e119c84321095bd2ee59c8fdcbdbf9651e41f51a24350acccfb8adbb134c82dd0dc13974b640bb0d69cc0955e0ed2
|
7
|
+
data.tar.gz: 77208ea90084bcb5da9e548001db1f4a777cf55eb4d2ec6f8e45125427bd8c1c267744443447d7199870381e6bb9b6af380c482b1df918588f436bc505bdc1b5
|
data/Gemfile.lock
CHANGED
data/lib/jira_sync/plugin.rb
CHANGED
@@ -92,7 +92,7 @@ module Danger
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def github_labels
|
95
|
-
@github_labels ||= github.api.labels(repo)
|
95
|
+
@github_labels ||= github.api.labels(repo).map { |github_label| github_label[:name] }
|
96
96
|
rescue Octokit::Error => e
|
97
97
|
warn "#{e.response_status} Error while retrieving GitHub labels: #{e.message}"
|
98
98
|
end
|
data/spec/jira_sync_spec.rb
CHANGED
@@ -130,8 +130,21 @@ RSpec.describe Danger::DangerJiraSync do
|
|
130
130
|
plugin.configure(jira_settings)
|
131
131
|
end
|
132
132
|
|
133
|
+
def github_labels_response(labels)
|
134
|
+
labels.map do |label|
|
135
|
+
{
|
136
|
+
id: SecureRandom.random_number(100_000),
|
137
|
+
node_id: SecureRandom.base64,
|
138
|
+
url: "https://api.github.com/repos/<someorg>/<somerepo>/labels/#{label}",
|
139
|
+
name: label,
|
140
|
+
color: SecureRandom.hex(3),
|
141
|
+
default: false
|
142
|
+
}
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
133
146
|
def stub_github_api_labelling(labels: [])
|
134
|
-
allow(github_api_mock).to receive(:labels).and_return(labels)
|
147
|
+
allow(github_api_mock).to receive(:labels).and_return(github_labels_response(labels))
|
135
148
|
allow(github_api_mock).to receive(:add_label).and_return(nil)
|
136
149
|
allow(github_api_mock).to receive(:add_labels_to_an_issue).and_return(nil)
|
137
150
|
|
@@ -278,7 +291,7 @@ RSpec.describe Danger::DangerJiraSync do
|
|
278
291
|
expect(dangerfile.status_report[:warnings].count).to eq(expected_missing_label_count)
|
279
292
|
end
|
280
293
|
|
281
|
-
it "creates a warning when it cannot
|
294
|
+
it "creates a warning when it cannot add a label to an existing github issue" do
|
282
295
|
stub_github_api_labelling
|
283
296
|
|
284
297
|
error = Octokit::Error.from_response({
|
@@ -299,7 +312,7 @@ RSpec.describe Danger::DangerJiraSync do
|
|
299
312
|
expect(dangerfile.status_report[:warnings].count).to eq(1)
|
300
313
|
end
|
301
314
|
|
302
|
-
it "creates a warning when it cannot
|
315
|
+
it "creates a warning when it cannot fetch existing github labels" do
|
303
316
|
stub_github_api_labelling
|
304
317
|
|
305
318
|
error = Octokit::Error.from_response({
|
@@ -314,7 +327,7 @@ RSpec.describe Danger::DangerJiraSync do
|
|
314
327
|
HEREDOC
|
315
328
|
})
|
316
329
|
|
317
|
-
expect(github_api_mock).to receive(:
|
330
|
+
expect(github_api_mock).to receive(:labels).and_raise(error)
|
318
331
|
expect(dangerfile.status_report[:warnings].count).to eq(0), "preconditions"
|
319
332
|
|
320
333
|
VCR.use_cassette(:default_success, record: :new_episodes) do
|