Skip to content

Commit

Permalink
Stable Version 1.1.1.
Browse files Browse the repository at this point in the history
Fixes #46.
  • Loading branch information
jmdobry committed Feb 5, 2015
1 parent 1abe598 commit 3edfdd8
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 19 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
##### 1.1.1 - 05 February 2015

###### Backwards compatible bug fixes
- #46 - "actions" don't inherit basePath properly

##### 1.1.0 - 04 February 2015

##### Backwards compatible API changes
Expand Down
11 changes: 6 additions & 5 deletions dist/js-data-debug.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @author Jason Dobry <jason.dobry@gmail.com>
* @file dist/js-data-debug.js
* @version 1.1.0 - Homepage <http://www.js-data.io/>
* @version 1.1.1 - Homepage <http://www.js-data.io/>
* @copyright (c) 2014 Jason Dobry
* @license MIT <https://github.com/js-data/js-data/blob/master/LICENSE>
*
Expand Down Expand Up @@ -3667,18 +3667,19 @@ function defineResource(definition) {
}
def[name] = function (options) {
options = options || {};
var adapter = _this.getAdapter(action.adapter || 'http');
var config = DSUtils.deepMixIn({}, action);
if (!options.hasOwnProperty('endpoint') && config.endpoint) {
options.endpoint = config.endpoint;
}
if (typeof options.getEndpoint === 'function') {
config.url = options.getEndpoint(def, options);
} else {
config.url = DSUtils.makePath(def.getEndpoint(null, options), name);
config.url = DSUtils.makePath(options.basePath || adapter.defaults.basePath || def.basePath, def.getEndpoint(null, options), name);
}
config.method = config.method || 'GET';
DSUtils.deepMixIn(config, options);
return _this.getAdapter(action.adapter || 'http').HTTP(config);
return adapter.HTTP(config);
};
});

Expand Down Expand Up @@ -4663,10 +4664,10 @@ module.exports = {
DSUtils: require('./utils'),
DSErrors: require('./errors'),
version: {
full: '1.1.0',
full: '1.1.1',
major: parseInt('1', 10),
minor: parseInt('1', 10),
patch: parseInt('0', 10),
patch: parseInt('1', 10),
alpha: 'false' !== 'false' ? 'false' : false,
beta: 'false' !== 'false' ? 'false' : false
}
Expand Down
11 changes: 6 additions & 5 deletions dist/js-data.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @author Jason Dobry <jason.dobry@gmail.com>
* @file dist/js-data.js
* @version 1.1.0 - Homepage <http://www.js-data.io/>
* @version 1.1.1 - Homepage <http://www.js-data.io/>
* @copyright (c) 2014 Jason Dobry
* @license MIT <https://github.com/js-data/js-data/blob/master/LICENSE>
*
Expand Down Expand Up @@ -3651,18 +3651,19 @@ function defineResource(definition) {
}
def[name] = function (options) {
options = options || {};
var adapter = _this.getAdapter(action.adapter || 'http');
var config = DSUtils.deepMixIn({}, action);
if (!options.hasOwnProperty('endpoint') && config.endpoint) {
options.endpoint = config.endpoint;
}
if (typeof options.getEndpoint === 'function') {
config.url = options.getEndpoint(def, options);
} else {
config.url = DSUtils.makePath(def.getEndpoint(null, options), name);
config.url = DSUtils.makePath(options.basePath || adapter.defaults.basePath || def.basePath, def.getEndpoint(null, options), name);
}
config.method = config.method || 'GET';
DSUtils.deepMixIn(config, options);
return _this.getAdapter(action.adapter || 'http').HTTP(config);
return adapter.HTTP(config);
};
});

Expand Down Expand Up @@ -4628,10 +4629,10 @@ module.exports = {
DSUtils: require('./utils'),
DSErrors: require('./errors'),
version: {
full: '1.1.0',
full: '1.1.1',
major: parseInt('1', 10),
minor: parseInt('1', 10),
patch: parseInt('0', 10),
patch: parseInt('1', 10),
alpha: 'false' !== 'false' ? 'false' : false,
beta: 'false' !== 'false' ? 'false' : false
}
Expand Down
4 changes: 2 additions & 2 deletions dist/js-data.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "js-data",
"description": "Robust, framework-agnostic in-memory data store.",
"version": "1.1.0",
"version": "1.1.1",
"homepage": "http://www.js-data.io",
"repository": {
"type": "git",
Expand Down
5 changes: 3 additions & 2 deletions src/datastore/sync_methods/defineResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,18 +294,19 @@ function defineResource(definition) {
}
def[name] = function (options) {
options = options || {};
var adapter = _this.getAdapter(action.adapter || 'http');
var config = DSUtils.deepMixIn({}, action);
if (!options.hasOwnProperty('endpoint') && config.endpoint) {
options.endpoint = config.endpoint;
}
if (typeof options.getEndpoint === 'function') {
config.url = options.getEndpoint(def, options);
} else {
config.url = DSUtils.makePath(def.getEndpoint(null, options), name);
config.url = DSUtils.makePath(options.basePath || adapter.defaults.basePath || def.basePath, def.getEndpoint(null, options), name);
}
config.method = config.method || 'GET';
DSUtils.deepMixIn(config, options);
return _this.getAdapter(action.adapter || 'http').HTTP(config);
return adapter.HTTP(config);
};
});

Expand Down
10 changes: 6 additions & 4 deletions test/browser/datastore/sync_methods/defineResource.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ describe('DS#defineResource', function () {
var _this = this;
var newStore = new JSData.DS({
debug: false,
basePath: 'http://foo.com',
actions: {
test: {
method: 'POST'
Expand Down Expand Up @@ -260,7 +261,7 @@ describe('DS#defineResource', function () {
setTimeout(function () {
try {
assert.equal(2, _this.requests.length);
assert.equal(_this.requests[1].url, 'thing2/count');
assert.equal(_this.requests[1].url, 'http://foo.com/thing2/count');
assert.equal(_this.requests[1].method, 'POST');
_this.requests[1].respond(200, { 'Content-Type': 'text/plain' }, 'stuff2');
} catch (err) {
Expand All @@ -272,7 +273,7 @@ describe('DS#defineResource', function () {
setTimeout(function () {
try {
assert.equal(1, _this.requests.length);
assert.equal(_this.requests[0].url, 'thing2/test');
assert.equal(_this.requests[0].url, 'http://foo.com/thing2/test');
assert.equal(_this.requests[0].method, 'POST');
assert.equal(_this.requests[0].requestBody, 'thing2 payload');
_this.requests[0].respond(200, { 'Content-Type': 'text/plain' }, 'stuff');
Expand All @@ -298,6 +299,7 @@ describe('DS#defineResource', function () {

var Thing = newStore.defineResource({
name: 'thing',
endpoint: 'foo',
actions: {
count: {
method: 'GET',
Expand Down Expand Up @@ -330,7 +332,7 @@ describe('DS#defineResource', function () {

setTimeout(function () {
assert.equal(2, _this.requests.length);
assert.equal(_this.requests[1].url, 'thing/count');
assert.equal(_this.requests[1].url, 'foo/count');
assert.equal(_this.requests[1].method, 'GET');
_this.requests[1].respond(200, { 'Content-Type': 'text/plain' }, 'stuff2');

Expand All @@ -339,7 +341,7 @@ describe('DS#defineResource', function () {

setTimeout(function () {
assert.equal(1, _this.requests.length);
assert.equal(_this.requests[0].url, 'thing/test');
assert.equal(_this.requests[0].url, 'foo/test');
assert.equal(_this.requests[0].method, 'GET');
_this.requests[0].respond(200, { 'Content-Type': 'text/plain' }, 'stuff');
}, 30);
Expand Down

1 comment on commit 3edfdd8

@antoinebrault
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Model Definition basepath should be taken before Adapter basePath:

config.url = DSUtils.makePath(options.basePath || adapter.defaults.basePath || def.basePath, def.getEndpoint(null, options), name);

should be:

config.url = DSUtils.makePath(options.basePath || def.basePath || adapter.defaults.basePath, def.getEndpoint(null, options), name);

Please sign in to comment.