This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Add hasBody to ngResource action configuration #12181
Closed
Closed
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
745d347
Added hasBody to ngResource action configuration
kaufholdr c6f2687
Refined version of hasBody check.
kaufholdr 9e23624
Fixed documentation of ngResource.hasBody configuration.
kaufholdr be8aeeb
Improved documentation of ngResource.hasBody that only POST, PUT and …
kaufholdr c8212ad
Added unit test for ngResource.hasBody.
kaufholdr cf811f5
Added additional test case for hasBody: false on POST,PUT and PATCH
kaufholdr 36ce9f0
Cleanup of hasBody test case variables.
kaufholdr 9139302
Enhanced test case on methods with hasBody true.
kaufholdr 77d9cfa
Further improvement of unit tests for ngResource hasBody.
kaufholdr 4e2a874
Changed expects of hasBody test to refere to a response value instead…
kaufholdr 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -97,6 +97,43 @@ describe('basic usage', function() { | |
$httpBackend.flush(); | ||
}); | ||
|
||
it('should include a request body when calling custom delete with hasBody is true', function() { | ||
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. custom delete --> custom method Can you also test with another method (in the same test), just to avoid giving the impression this is just about |
||
var condition = {at: '2038-01-19 03:14:08'}; | ||
$httpBackend.expect('DELETE', '/fooresource', condition).respond({}); | ||
|
||
var r = $resource('/fooresource', {}, { | ||
delete: {method: 'DELETE', hasBody: true} | ||
}); | ||
|
||
var deleteResponse = r.delete(condition); | ||
|
||
$httpBackend.flush(); | ||
|
||
expect(deleteResponse.$resolved).toBe(true); | ||
}); | ||
|
||
it('should expect a body if hasBody is true', function() { | ||
var username = 'yathos'; | ||
var loginRequest = {name: username, password: 'Smile'}; | ||
var user = {id: 1, name: username}; | ||
|
||
$httpBackend.expect('LOGIN', '/user/me', loginRequest).respond(user); | ||
|
||
$httpBackend.expect('LOGOUT', '/user/me', null).respond(null); | ||
|
||
var UserService = $resource('/user/me', {}, { | ||
login: {method: 'LOGIN', hasBody: true}, | ||
logout: {method: 'LOGOUT', hasBody: false} | ||
}); | ||
|
||
var loginResponse = UserService.login(loginRequest); | ||
var logoutResponse = UserService.logout(); | ||
|
||
$httpBackend.flush(); | ||
|
||
expect(loginResponse.id).toBe(user.id); | ||
expect(logoutResponse.$resolved).toBe(true); | ||
}); | ||
|
||
it('should build resource', function() { | ||
expect(typeof CreditCard).toBe('function'); | ||
|
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.
only POST, PUT and PATCH will have a request --> only POST, PUT and PATCH requests will have a body