Skip to content

Commit e23bcf6

Browse files
committed
Fix label parameters validation
No parameter are mandatory for updating an existing label, but when creating one, a name is required. https://docs.github.com/en/rest/reference/issues#create-a-label
1 parent 455b98b commit e23bcf6

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

lib/github_api/client/issues/labels.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def get(*args)
8080
def create(*args)
8181
arguments(args, required: [:user, :repo]) do
8282
permit VALID_LABEL_INPUTS
83-
assert_required VALID_LABEL_INPUTS
83+
assert_required %w[ name color ]
8484
end
8585

8686
post_request("/repos/#{arguments.user}/#{arguments.repo}/labels", arguments.params)
@@ -103,7 +103,6 @@ def create(*args)
103103
def update(*args)
104104
arguments(args, required: [:user, :repo, :label_name]) do
105105
permit VALID_LABEL_INPUTS
106-
assert_required VALID_LABEL_INPUTS
107106
end
108107

109108
patch_request("/repos/#{arguments.user}/#{arguments.repo}/labels/#{arguments.label_name}", arguments.params)

spec/github/client/issues/labels/update_spec.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,6 @@
2626
let(:body) { fixture('issues/label.json') }
2727
let(:status) { 200 }
2828

29-
it "should fail to create resource if 'name' input is missing" do
30-
expect {
31-
subject.update user, repo, label_id, inputs.except('name')
32-
}.to raise_error(Github::Error::RequiredParams)
33-
end
34-
35-
it "should fail to create resource if 'color' input is missing" do
36-
expect {
37-
subject.update user, repo, label_id, inputs.except('color')
38-
}.to raise_error(Github::Error::RequiredParams)
39-
end
40-
4129
it "should update resource successfully" do
4230
subject.update user, repo, label_id, inputs
4331
expect(a_patch(request_path).with(body: inputs)).to have_been_made

0 commit comments

Comments
 (0)