Skip to content

Commit

Permalink
add convenient methods to change a state of an issue
Browse files Browse the repository at this point in the history
  • Loading branch information
NARKOZ committed Sep 23, 2012
1 parent f7f2dc3 commit 53746d5
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/gitlab/client/issues.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,31 @@ def create_issue(project, title, options={})
def edit_issue(project, id, options={})
put("/projects/#{project}/issues/#{id}", :body => options)
end

# Closes an issue.
#
# @example
# Gitlab.close_issue(3, 42)
# Gitlab.close_issue('gitlab', 42)
#
# @param [Integer, String] project The ID or code name of a project.
# @param [Integer] id The ID of an issue.
# @return [Gitlab::ObjectifiedHash] Information about closed issue.
def close_issue(project, id)
put("/projects/#{project}/issues/#{id}", :body => {:closed => 1})
end

# Reopens an issue.
#
# @example
# Gitlab.reopen_issue(3, 42)
# Gitlab.reopen_issue('gitlab', 42)
#
# @param [Integer, String] project The ID or code name of a project.
# @param [Integer] id The ID of an issue.
# @return [Gitlab::ObjectifiedHash] Information about reopened issue.
def reopen_issue(project, id)
put("/projects/#{project}/issues/#{id}", :body => {:closed => 0})
end
end
end
34 changes: 34 additions & 0 deletions spec/gitlab/client/issues_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,38 @@
@issue.assignee.name.should == "Jack Smith"
end
end

describe ".close_issue" do
before do
stub_put("/projects/3/issues/33", "issue")
@issue = Gitlab.close_issue(3, 33)
end

it "should get the correct resource" do
a_put("/projects/3/issues/33").
with(:body => {:closed => '1'}).should have_been_made
end

it "should return information about an edited issue" do
@issue.project_id.should == 3
@issue.assignee.name.should == "Jack Smith"
end
end

describe ".reopen_issue" do
before do
stub_put("/projects/3/issues/33", "issue")
@issue = Gitlab.reopen_issue(3, 33)
end

it "should get the correct resource" do
a_put("/projects/3/issues/33").
with(:body => {:closed => '0'}).should have_been_made
end

it "should return information about an edited issue" do
@issue.project_id.should == 3
@issue.assignee.name.should == "Jack Smith"
end
end
end

0 comments on commit 53746d5

Please sign in to comment.