Skip to content

Commit

Permalink
Merge pull request #23 from robertomiranda/update-user
Browse files Browse the repository at this point in the history
Add Method for Update a User
  • Loading branch information
NARKOZ committed Dec 8, 2013
2 parents 54e744a + 7152c85 commit 5877e24
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ test/tmp
test/version_tmp
tmp
.idea
.ruby-version
.ruby-gemset
17 changes: 17 additions & 0 deletions lib/gitlab/client/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ def create_user(email, password, options={})
post("/users", :body => body)
end

# Update a user.
# Requires authentication from an admin account.
#
# @param [String] The user's id
# @param [Hash] options A customizable set of options.
# @option options [String] email The email of a user.
# @option options [String] password The password of a user.
# @option options [String] :name The name of a user. Defaults to email.
# @option options [String] :skype The skype of a user.
# @option options [String] :linkedin The linkedin of a user.
# @option options [String] :twitter The twitter of a user.
# @option options [Integer] :projects_limit The limit of projects for a user.
# @return [Gitlab::ObjectifiedHash] Information about created user.
def edit_user(user_id, options={})
put("/users/#{user_id}", :body => options)
end

# Creates a new user session.
#
# @example
Expand Down
12 changes: 12 additions & 0 deletions spec/gitlab/client/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@
end
end

describe ".edit_user" do
before do
@options = { :name => "Roberto" }
stub_put("/users/1", "user").with(:body => @options)
@user = Gitlab.edit_user(1, @options)
end

it "should get the correct resource" do
a_put("/users/1").with(:body => @options).should have_been_made
end
end

describe ".session" do
before do
stub_post("/session", "session")
Expand Down

0 comments on commit 5877e24

Please sign in to comment.