Skip to content

Commit d39aa34

Browse files
author
Sam Davies
committed
Delete a project
1 parent ae06e95 commit d39aa34

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

lib/github_api/client/projects.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,19 @@ def edit(*args)
5555

5656
patch_request("/projects/#{arguments.id}",params)
5757
end
58+
59+
# Delete a project
60+
#
61+
# @example
62+
# github = Github.new
63+
# github.projects.delete 1002604
64+
#
65+
# @api public
66+
def delete(*args)
67+
arguments(args, required: [:id])
68+
69+
delete_request("/projects/#{arguments.id}", arguments.params)
70+
end
71+
alias :remove :delete
5872
end # Projects
5973
end # Github
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe Github::Client::Projects, '#delete' do
6+
let(:project_id) { 1002604 }
7+
let(:request_path) { "/projects/#{project_id}" }
8+
let(:body) { '' }
9+
let(:status) { 204 }
10+
11+
before {
12+
stub_delete(request_path).to_return(:body => body, :status => status,
13+
:headers => { :content_type => "application/json; charset=utf-8"})
14+
}
15+
16+
after { reset_authentication_for subject }
17+
18+
it { should respond_to :remove }
19+
20+
it "should delete the resource successfully" do
21+
subject.delete project_id
22+
a_delete(request_path).should have_been_made
23+
end
24+
25+
it "should fail to delete resource without 'id' parameter" do
26+
expect { subject.delete }.to raise_error(ArgumentError)
27+
end
28+
29+
it_should_behave_like 'request failure' do
30+
let(:requestable) { subject.delete project_id }
31+
end
32+
end # delete

0 commit comments

Comments
 (0)