Skip to content

Commit

Permalink
removed support for fixture adapter. moved ember-data to devDependenc…
Browse files Browse the repository at this point in the history
…y in bower
  • Loading branch information
danielspaniel committed Apr 12, 2015
1 parent 3271a25 commit 54e362a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 18 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
],
"license": "MIT",
"dependencies": {
"ember-data": "1.0.0-beta.16",
"jquery-mockjax": "latest"
},
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"blueprints",
"bower.json",
"gruntfile.js",
"package.json",
Expand All @@ -31,6 +31,7 @@
"tests"
],
"devDependencies": {
"ember-data": "1.0.0-beta.16",
"chance": "latest",
"qunit": "latest",
"sinon": "http://sinonjs.org/releases/sinon-1.10.1.js",
Expand Down
6 changes: 5 additions & 1 deletion dist/amd/factory-guy.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ var FactoryGuy = {
}
}
},

/**
Push fixture to model's FIXTURES array.
Used when store's adapter is a DS.FixtureAdapter.
Expand Down Expand Up @@ -748,7 +749,9 @@ var MockUpdateRequest = function(url, model, mapFind, options) {
this.responseText = response;
}
} else {
var json = model.toJSON({includeId: true});
// need to serialize instead of toJSON for polymorphic associations
var json = model.serialize();
json.id = model.id;
this.responseText = mapFind(model.constructor.typeKey, json);
this.status = 200;
}
Expand All @@ -763,6 +766,7 @@ var MockUpdateRequest = function(url, model, mapFind, options) {

$.mockjax(requestConfig);
};

(function () {
DS.Store.reopen({
/**
Expand Down
5 changes: 4 additions & 1 deletion dist/ember-data-factory-guy.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,9 @@ var MockUpdateRequest = function(url, model, mapFind, options) {
this.responseText = response;
}
} else {
var json = model.toJSON({includeId: true});
// need to serialize instead of toJSON for polymorphic associations
var json = model.serialize();
json.id = model.id;
this.responseText = mapFind(model.constructor.typeKey, json);
this.status = 200;
}
Expand All @@ -759,6 +761,7 @@ var MockUpdateRequest = function(url, model, mapFind, options) {

$.mockjax(requestConfig);
};

(function () {
DS.Store.reopen({
/**
Expand Down
2 changes: 1 addition & 1 deletion dist/ember-data-factory-guy.min.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/mock_update_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ var MockUpdateRequest = function(url, model, mapFind, options) {
this.responseText = response;
}
} else {
var json = model.toJSON({includeId: true});
// need to serialize instead of toJSON for polymorphic associations
var json = model.serialize();
json.id = model.id;
this.responseText = mapFind(model.constructor.typeKey, json);
this.status = 200;
}
Expand All @@ -46,4 +48,4 @@ var MockUpdateRequest = function(url, model, mapFind, options) {
};

$.mockjax(requestConfig);
};
};
5 changes: 0 additions & 5 deletions tests/test_setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ Project = DS.Model.extend({
children: DS.hasMany('project', {inverse: 'parent'})
});






Property = DS.Model.extend({
name: DS.attr('string'),
company: DS.belongsTo('company', {async: true}),
Expand Down
16 changes: 9 additions & 7 deletions vendor/assets/javascripts/ember_data_factory_guy.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ var FactoryGuy = {
}
}
},

/**
Push fixture to model's FIXTURES array.
Used when store's adapter is a DS.FixtureAdapter.
Expand Down Expand Up @@ -743,7 +744,9 @@ var MockUpdateRequest = function(url, model, mapFind, options) {
this.responseText = response;
}
} else {
var json = model.toJSON({includeId: true});
// need to serialize instead of toJSON for polymorphic associations
var json = model.serialize();
json.id = model.id;
this.responseText = mapFind(model.constructor.typeKey, json);
this.status = 200;
}
Expand All @@ -758,6 +761,7 @@ var MockUpdateRequest = function(url, model, mapFind, options) {

$.mockjax(requestConfig);
};

(function () {
DS.Store.reopen({
/**
Expand Down Expand Up @@ -1338,12 +1342,10 @@ if (FactoryGuy !== undefined) {
return null;
}
}

// Inspect the data submitted in the request (either POST body or GET query string)
if ( handler.data ) {
// console.log('request.data', requestSettings.data )
// console.log('handler.data', handler.data )
// console.log('data equal', isMockDataEqual(handler.data, requestSettings.data) )
if ( ! requestSettings.data || !isMockDataEqual(handler.data, requestSettings.data) ) {
if ( ! requestSettings.data || !isMockDataEqual(handler.data, requestSettings.data) ) {
// They're not identical, do not mock this request
return null;
}
Expand All @@ -1354,6 +1356,7 @@ if (FactoryGuy !== undefined) {
// The request type doesn't match (GET vs. POST)
return null;
}

return handler;
}

Expand Down Expand Up @@ -1717,7 +1720,6 @@ if (FactoryGuy !== undefined) {
}

mockHandler = getMockForRequest( mockHandlers[k], requestSettings );

if(!mockHandler) {
// No valid mock found for this request
continue;
Expand Down Expand Up @@ -1769,7 +1771,7 @@ if (FactoryGuy !== undefined) {
}

copyUrlParameters(mockHandler, origSettings);
//console.log('here copyUrlParameters', 'mockHandler=>',mockHandler, 'requestSettings=>',requestSettings, 'origSettings=>',origSettings)

(function(mockHandler, requestSettings, origSettings, origHandler) {

mockRequest = _ajax.call($, $.extend(true, {}, origSettings, {
Expand Down

0 comments on commit 54e362a

Please sign in to comment.