mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
make xhr just a method
This commit is contained in:
parent
2df072e3f8
commit
c9aba8b442
5 changed files with 12 additions and 7 deletions
|
|
@ -7,7 +7,7 @@ $(document).ready(function(){
|
|||
})
|
||||
}
|
||||
|
||||
var resourceFactory = new ResourceFactory({method: xhr});
|
||||
var resourceFactory = new ResourceFactory(xhr);
|
||||
|
||||
var Tweeter = resourceFactory.route("http://twitter.com/statuses/:service:username.json", {}, {
|
||||
home: {method:'GET', params: {service:'home_timeline'}, isArray:true },
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ load:
|
|||
- lib/underscore/underscore.js
|
||||
- src/Angular.js
|
||||
- src/*.js
|
||||
- src/test/_namespace.js
|
||||
- src/test/*.js
|
||||
- src/scenario/_namespace.js
|
||||
- src/scenario/*.js
|
||||
- test/testabilityPatch.js
|
||||
- test/test/*.js
|
||||
- test/scenario/*.js
|
||||
- test/*.js
|
||||
|
||||
exclude:
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ ResourceFactory.prototype = {
|
|||
}
|
||||
|
||||
var value = action.isArray ? [] : new Resource(data);
|
||||
self.xhr.method(action.method, route.url($.extend({}, action.params || {}, extractParams(data), params)), data, function(response) {
|
||||
self.xhr(action.method, route.url($.extend({}, action.params || {}, extractParams(data), params)), data, function(response) {
|
||||
if (action.isArray) {
|
||||
foreach(response, function(item){
|
||||
value.push(new Resource(item));
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ describe("resource", function() {
|
|||
|
||||
beforeEach(function(){
|
||||
xhr = new MockXHR();
|
||||
resource = new ResourceFactory(xhr);
|
||||
resource = new ResourceFactory(_(xhr.method).bind(xhr));
|
||||
CreditCard = resource.route('/CreditCard/:id:verb', {id:'@id.key'}, {
|
||||
charge:{
|
||||
method:'POST',
|
||||
|
|
@ -80,6 +80,11 @@ describe("resource", function() {
|
|||
expect(typeof CreditCard.query).toBe('function');
|
||||
});
|
||||
|
||||
it('should default to empty parameters', function(){
|
||||
xhr.expectGET('URL').respond({});
|
||||
resource.route('URL').query();
|
||||
});
|
||||
|
||||
it("should build resource with default param", function(){
|
||||
xhr.expectGET('/Order/123/Line/456.visa?minimum=0.05').respond({id:'abc'});
|
||||
var LineItem = resource.route('/Order/:orderId/Line/:id:verb', {orderId: '123', id: '@id.key', verb:'.visa', minimum:0.05});
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ StepsTest = TestCase("StepsTest");
|
|||
|
||||
StepsTest.prototype.testGivenDataset=function(){
|
||||
var self = {frame:{}, dataset:[]};
|
||||
angular.test.GIVEN.dataset.call(self);
|
||||
angular.scenario.GIVEN.dataset.call(self);
|
||||
assertEquals('$DATASET:{"dataset":[]}', self.frame.name);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue