peoplegroup-connectors 0.1.2 → 0.1.3
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/peoplegroup/connectors/version.rb +1 -1
- data/peoplegroup-connectors.gemspec +3 -6
- data/spec/peoplegroup/connectors/gitlab_spec.rb +125 -0
- data/spec/peoplegroup/connectors_spec.rb +7 -0
- data/spec/spec_helper.rb +18 -0
- metadata +12 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb962e9d43875bb0a19ac206165c335097c6147148d23944a4479e97460613f3
|
4
|
+
data.tar.gz: 521103c3b8289e98752fb6a06f125ed8db47ef5d160030032b00ab478263498d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d52daa4d4fddc9a989dc41e601d208167c6a27c36d1c2a0ba09b164c25a9eb829486bae15f09a64bb6c670f57ea803fc37e25966410761f2fefe11b165206700
|
7
|
+
data.tar.gz: 472b1e602fb9ae87b5b25fb6987e4d625a31b2b668c24429ab850adc06314980a7dbd8533f518104d475a554df9fe94b16ac87e365247137636acba14dbcf432
|
data/Gemfile.lock
CHANGED
@@ -18,14 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.metadata['source_code_uri'] = spec.homepage
|
19
19
|
spec.metadata['changelog_uri'] = spec.homepage
|
20
20
|
|
21
|
-
spec.files
|
22
|
-
|
23
|
-
|
24
|
-
spec.bindir = 'exe'
|
25
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.files = `git ls-files -z`.split("\x0")
|
22
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
23
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
26
24
|
spec.require_paths = ['lib']
|
27
25
|
|
28
|
-
|
29
26
|
spec.add_dependency 'gitlab'
|
30
27
|
|
31
28
|
spec.add_development_dependency 'rspec', '~> 3.2'
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe PeopleGroup::Connectors::GitLab do
|
4
|
+
let(:gitlab_members) { spy }
|
5
|
+
let(:gitlab_mock) do
|
6
|
+
instance_double(
|
7
|
+
Gitlab::Client,
|
8
|
+
group_members: gitlab_members,
|
9
|
+
create_issue: true,
|
10
|
+
issues: double(auto_paginate: true),
|
11
|
+
create_issue_note: true,
|
12
|
+
create_epic: true,
|
13
|
+
epics: double(auto_paginate: []),
|
14
|
+
create_branch: true,
|
15
|
+
create_merge_request: true,
|
16
|
+
create_commit: true,
|
17
|
+
create_epic_note: true,
|
18
|
+
epic_issues: double(auto_paginate: []),
|
19
|
+
edit_epic: true
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
before do
|
24
|
+
allow(Gitlab).to receive(:client).and_return(gitlab_mock)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#find_gitlabber' do
|
28
|
+
context 'when given empty query' do
|
29
|
+
it 'returns nil' do
|
30
|
+
expect(described_class.new.find_gitlabber(:username, nil)).to be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when given non-empty query' do
|
35
|
+
it 'calls correct method with proper args' do
|
36
|
+
described_class.new.find_gitlabber(:name, 'john')
|
37
|
+
|
38
|
+
expect(gitlab_mock).to have_received(:group_members).with('gitlab-com', query: 'john')
|
39
|
+
expect(gitlab_members).to have_received(:find)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#create_issue' do
|
45
|
+
it 'calls correct method with proper args' do
|
46
|
+
described_class.new.create_issue('foo/bar', 'My Issue Title', assignee_id: 123_456)
|
47
|
+
expect(gitlab_mock).to have_received(:create_issue).with('foo/bar', 'My Issue Title', assignee_id: 123_456)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#get_onboarding_issues' do
|
52
|
+
it 'uses specified arguments' do
|
53
|
+
described_class.new.get_onboarding_issues('foo/bar', per_page: 500)
|
54
|
+
|
55
|
+
expect(gitlab_mock).to have_received(:issues).with('foo/bar', per_page: 500)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#create_issue_note' do
|
60
|
+
it 'calls correct method with proper args' do
|
61
|
+
described_class.new.create_issue_note('foo/bar', 15, 'My issue comment')
|
62
|
+
|
63
|
+
expect(gitlab_mock).to have_received(:create_issue_note).with('foo/bar', 15, 'My issue comment')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#find_or_create_epic' do
|
68
|
+
it 'calls correct method with proper args' do
|
69
|
+
described_class.new.find_or_create_epic(123, 'My Epic Title', assignee_id: 123_456)
|
70
|
+
expect(gitlab_mock).to have_received(:create_epic).with(123, 'My Epic Title', { assignee_id: 123_456, confidential: true })
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when the epic was closed' do
|
74
|
+
before do
|
75
|
+
allow(gitlab_mock).to receive(:epics).and_return(double(auto_paginate: [double(iid: 1, group_id: 2, web_url: 'foo.bar/issues/1', state: 'closed', title: 'Existing Epic')]))
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'reopens the epic' do
|
79
|
+
described_class.new.find_or_create_epic(2, 'Existing Epic', assignee_id: 123_456)
|
80
|
+
expect(gitlab_mock).not_to have_received(:create_epic)
|
81
|
+
expect(gitlab_mock).to have_received(:edit_epic).with(2, 1, state_event: 'reopen')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#commit_change_to_new_merge_request' do
|
87
|
+
it 'calls correct method with proper args' do
|
88
|
+
described_class.new.commit_change_to_new_merge_request(123, 'my-new-branch', 'foo/bar.md', 'the changed text', 'my commit message')
|
89
|
+
expect(gitlab_mock).to have_received(:create_branch).with(123, 'my-new-branch', 'master')
|
90
|
+
action = {
|
91
|
+
action: 'update',
|
92
|
+
file_path: 'foo/bar.md',
|
93
|
+
content: 'the changed text'
|
94
|
+
}
|
95
|
+
expect(gitlab_mock).to have_received(:create_commit).with(123, 'my-new-branch', 'my commit message', [action])
|
96
|
+
expect(gitlab_mock).to have_received(:create_merge_request).with(123, 'my commit message', { source_branch: 'my-new-branch', target_branch: 'master', remove_source_branch: true })
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#get_epics' do
|
101
|
+
it 'calls correct method with proper args' do
|
102
|
+
described_class.new.get_epics(123)
|
103
|
+
expect(gitlab_mock).to have_received(:epics).with(123, {})
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'calls correct method with proper args when you add options' do
|
107
|
+
described_class.new.get_epics(123, state: 'opened')
|
108
|
+
expect(gitlab_mock).to have_received(:epics).with(123, { state: 'opened' })
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe '#get_issue_epics' do
|
113
|
+
it 'calls correct method with proper args' do
|
114
|
+
described_class.new.get_issue_epics(123, 7)
|
115
|
+
expect(gitlab_mock).to have_received(:epic_issues).with(123, 7)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#create_epic_note' do
|
120
|
+
it 'calls correct method with proper args' do
|
121
|
+
described_class.new.create_epic_note(123, 7, 'My epic note')
|
122
|
+
expect(gitlab_mock).to have_received(:create_epic_note).with(123, 7, 'My epic note')
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'peoplegroup/connectors'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
# Enable flags like --only-failures and --next-failure
|
7
|
+
config.example_status_persistence_file_path = '.rspec_status'
|
8
|
+
|
9
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
10
|
+
config.disable_monkey_patching!
|
11
|
+
|
12
|
+
config.filter_run focus: true
|
13
|
+
config.run_all_when_everything_filtered = true
|
14
|
+
|
15
|
+
config.expect_with :rspec do |c|
|
16
|
+
c.syntax = :expect
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peoplegroup-connectors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lien van den steen
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2021-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
@@ -83,7 +83,9 @@ dependencies:
|
|
83
83
|
description: Avoid repeating methods in different projects for our connectos.
|
84
84
|
email:
|
85
85
|
- lvandensteen@gitlab.com
|
86
|
-
executables:
|
86
|
+
executables:
|
87
|
+
- console
|
88
|
+
- setup
|
87
89
|
extensions: []
|
88
90
|
extra_rdoc_files: []
|
89
91
|
files:
|
@@ -104,6 +106,9 @@ files:
|
|
104
106
|
- lib/peoplegroup/connectors/gitlab.rb
|
105
107
|
- lib/peoplegroup/connectors/version.rb
|
106
108
|
- peoplegroup-connectors.gemspec
|
109
|
+
- spec/peoplegroup/connectors/gitlab_spec.rb
|
110
|
+
- spec/peoplegroup/connectors_spec.rb
|
111
|
+
- spec/spec_helper.rb
|
107
112
|
homepage: https://gitlab.com/gitlab-com/people-group/peopleops-eng/connectors-gem
|
108
113
|
licenses:
|
109
114
|
- MIT
|
@@ -130,4 +135,7 @@ rubygems_version: 3.1.4
|
|
130
135
|
signing_key:
|
131
136
|
specification_version: 4
|
132
137
|
summary: Library for our shared connectors.
|
133
|
-
test_files:
|
138
|
+
test_files:
|
139
|
+
- spec/peoplegroup/connectors/gitlab_spec.rb
|
140
|
+
- spec/peoplegroup/connectors_spec.rb
|
141
|
+
- spec/spec_helper.rb
|