Skip to content

Commit

Permalink
Merge pull request Shopify#15 from Shopify/partial-user
Browse files Browse the repository at this point in the history
Address partial user update using POST not PUT
  • Loading branch information
jules2689 authored Feb 4, 2019
2 parents 3ffb4ef + 1b5f02c commit 5670f09
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
sudo: false
before_install: gem install bundler
rvm:
- '2.2'
- '2.3.1'
- '2.3.8'
- '2.5.3'
- '2.6.0'

7 changes: 6 additions & 1 deletion lib/oktakit/client/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ def list_users(options = {})
# @param options[:headers] [Hash] Optional. Header params for the request.
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
# @param options[:partial] [Boolean] Indicates a partial update, in which case POST will be used instead of PUT
# @param options [Hash] Optional. Body params for request.
# @return [Hash<Sawyer::Resource>] Updated User
# @see https://developer.okta.com/docs/api/resources/users#update-user
# @example
# Oktakit.update_user('id')
def update_user(id, options = {})
put("/users/#{id}", options)
if options.delete(:partial)
post("/users/#{id}", options)
else
put("/users/#{id}", options)
end
end

# Update Profile
Expand Down
62 changes: 62 additions & 0 deletions spec/cassettes/update_user_partial.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions spec/client/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@
end
end

describe '#update_user partial' do
it 'returns updated user' do
VCR.use_cassette 'update_user_partial' do
resp, = client.update_user(USERS_USER_ID,
profile: {
firstName: "Bob",
lastName: "User",
email: "[email protected]",
login: "[email protected]"
},
partial: true)
expect(resp.profile.firstName).to be == 'Bob'
end
end
end

describe '#update_profile' do
it 'returns updated user' do
VCR.use_cassette 'update_profile' do
Expand Down

0 comments on commit 5670f09

Please sign in to comment.