-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support batch update resources #344
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b4db278
Batch update at update_many
otoyo 6f795dc
Merge remote-tracking branch 'origin/master' into batch-update
otoyo ac3225d
Merge remote-tracking branch 'origin/master' into batch-update
otoyo af5739b
Rename the variable
otoyo 4016981
Fix spec context
otoyo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,22 +47,44 @@ | |
subject { ZendeskAPI::BulkTestResource } | ||
|
||
context "update_many!" do | ||
let(:attributes) { { :name => 'A', :age => 25 } } | ||
context "arity: 3" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
let(:attributes) { { :name => 'A', :age => 25 } } | ||
|
||
before(:each) do | ||
stub_json_request(:put, %r{bulk_test_resources/update_many}, json(:job_status => { :id => 'ghi' })) | ||
@response = subject.update_many!(client, [1, 2, 3], attributes) | ||
end | ||
before(:each) do | ||
stub_json_request(:put, %r{bulk_test_resources/update_many}, json(:job_status => { :id => 'ghi' })) | ||
@response = subject.update_many!(client, [1, 2, 3], attributes) | ||
end | ||
|
||
it 'calls the update_many endpoint' do | ||
assert_requested(:put, %r{bulk_test_resources/update_many\?ids=1,2,3$}, | ||
:body => json(:bulk_test_resource => attributes) | ||
) | ||
end | ||
|
||
it 'calls the update_many endpoint' do | ||
assert_requested(:put, %r{bulk_test_resources/update_many\?ids=1,2,3$}, | ||
:body => json(:bulk_test_resource => attributes) | ||
) | ||
it 'returns a JobStatus' do | ||
expect(@response).to be_instance_of(ZendeskAPI::JobStatus) | ||
expect(@response.id).to eq('ghi') | ||
end | ||
end | ||
|
||
it 'returns a JobStatus' do | ||
expect(@response).to be_instance_of(ZendeskAPI::JobStatus) | ||
expect(@response.id).to eq('ghi') | ||
context "arity: 2" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
let(:attributes_array) { [{ :id => 1, :name => 'A' }, { :id => 2, :name => 'B' }] } | ||
|
||
before(:each) do | ||
stub_json_request(:put, %r{bulk_test_resources/update_many}, json(:job_status => { :id => 'jkl' })) | ||
@response = subject.update_many!(client, attributes_array) | ||
end | ||
|
||
it 'calls the update_many endpoint' do | ||
assert_requested(:put, %r{bulk_test_resources/update_many$}, | ||
:body => json(:bulk_test_resources => attributes_array) | ||
) | ||
end | ||
|
||
it 'returns a JobStatus' do | ||
expect(@response).to be_instance_of(ZendeskAPI::JobStatus) | ||
expect(@response.id).to eq('jkl') | ||
end | ||
end | ||
end | ||
end | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ids_or_attributes_array
naming looks not good to me...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave off the _array ... and make
attributes=nil
to mke the check simplerThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me but L283 might need conditions.