Skip to content

Commit

Permalink
Merge pull request #114 from SimonLab/remove-label-issue
Browse files Browse the repository at this point in the history
add support for removing a label from an issue
  • Loading branch information
edgurgel authored Apr 19, 2017
2 parents 6883e50 + 026e1bb commit e409566
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/tentacat/issues/labels.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,18 @@ defmodule Tentacat.Issues.Labels do
def add(owner, repo, issue_id, labels, client \\ %Client{}) do
post "repos/#{owner}/#{repo}/issues/#{issue_id}/labels", client, labels
end

@doc """
Remove a label from an issue
## Example
Tentacat.Issues.Labels.remove "elixir-lang", "elixir", 3970, "Important"
More info at: https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue
"""
@spec remove(binary, binary, binary | integer, binary, Client.t) :: Tentacat.response
def remove(owner, repo, issue_id, label, client \\ %Client{}) do
delete "repos/#{owner}/#{repo}/issues/#{issue_id}/labels/#{label}", client
end
end
42 changes: 42 additions & 0 deletions test/fixture/vcr_cassettes/issues/labels#remove.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"request": {
"body": "\"\"",
"headers": {
"User-agent": "tentacat"
},
"method": "delete",
"options": [],
"request_body": "",
"url": "https://api.github.com/repos/dwyl/learn-elixir/issues/1/labels/WIP"
},
"response": {
"body": "",
"headers": {
"Server": "GitHub.com",
"Date": "Wed, 19 Apr 2017 15:38:42 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "2260",
"Status": "200 OK",
"X-RateLimit-Limit": "60",
"X-RateLimit-Remaining": "42",
"X-RateLimit-Reset": "1465314971",
"Cache-Control": "public, max-age=60, s-maxage=60",
"Vary": "Accept",
"ETag": "\"1598b9c2c9191001f30226e51a54afb2\"",
"X-GitHub-Media-Type": "github.v3; format=json",
"Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval",
"Access-Control-Allow-Origin": "*",
"Content-Security-Policy": "default-src 'none'",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "deny",
"X-XSS-Protection": "1; mode=block",
"X-Served-By": "318e55760cf7cdb40e61175a4d36cd32",
"X-GitHub-Request-Id": "32E9B27E:B216:239A2390:5756E46C"
},
"status_code": 204,
"type": "ok"
}
}
]
7 changes: 7 additions & 0 deletions test/issues/labels_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@ defmodule Tentacat.Issues.LabelsTest do
assert name == "WIP"
end
end

test "remove/5" do
use_cassette "issues/labels#remove" do
{status_code, _} = remove("dwyl", "learn-elixir", "1", "WIP", @client)
assert status_code == 204
end
end
end

0 comments on commit e409566

Please sign in to comment.