Skip to content

Commit

Permalink
Add create_tag method. Add tests for new method.
Browse files Browse the repository at this point in the history
  • Loading branch information
asedge committed May 29, 2014
1 parent e8eefe2 commit 8c2aa8f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/gitlab/client/repositories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ def tags(project, options={})
end
alias_method :repo_tags, :tags

# Creates a new project repository tag.
#
# @example
# Gitlab.create_tag(42,'new_tag','master'))
#
# @param [Integer] project The ID of a project.
# @param [String] tag_name The name of the new tag.
# @param [String] ref The ref (commit sha, branch name, or another tag) the tag will point to.
# @return [Gitlab::ObjectifiedHash]
def create_tag(project, tag_name, ref)
post("/projects/#{project}/repository/tags", body: {tag_name: tag_name, ref: ref})
end
alias_method :repo_create_tag, :create_tag

# Gets a list of project commits.
#
# @example
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/tag.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "v1.0.0","commit": {"id": "2695effb5807a22ff3d138d593fd856244e155e7","parents": [],"message": "Initial commit","authored_date": "2012-05-28T04:42:42-07:00","author_name": "John Smith","author email": "john@example.com","committer_name": "Jack Smith","committed_date": "2012-05-28T04:42:42-07:00","committer_email": "jack@example.com"},"protected": false}
16 changes: 16 additions & 0 deletions spec/gitlab/client/repositories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

describe Gitlab::Client do
it { should respond_to :repo_tags }
it { should respond_to :repo_create_tag }
it { should respond_to :repo_branches }
it { should respond_to :repo_branch }
it { should respond_to :repo_commits }
Expand All @@ -24,6 +25,21 @@
end
end

describe ".create_tag" do
before do
stub_post("/projects/3/repository/tags", "tag")
@tag = Gitlab.create_tag(3,'v1.0.0','2695effb5807a22ff3d138d593fd856244e155e7')
end

it "should get the correct resource" do
a_post("/projects/3/repository/tags").should have_been_made
end

it "should return information about a new repository tag" do
@tag.name.should == 'v1.0.0'
end
end

describe ".commits" do
before do
stub_get("/projects/3/repository/commits", "project_commits").
Expand Down

0 comments on commit 8c2aa8f

Please sign in to comment.