Skip to content

Commit

Permalink
user -> owner
Browse files Browse the repository at this point in the history
  • Loading branch information
willwhite committed Jul 30, 2015
1 parent 4fd4a92 commit 3b9e1a0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions lib/make_service.js
Expand Up @@ -23,12 +23,12 @@ function makeService(name) {
}
if (options.account) {
invariant(typeof options.account === 'string', 'account must be a string');
this.user = options.account;
this.owner = options.account;
}
}

this.user = this.user || getUser(accessToken);
invariant(!!this.user, 'could not determine user from provided accessToken');
this.owner = this.owner || getUser(accessToken);
invariant(!!this.owner, 'could not determine account from provided accessToken');

}

Expand Down
20 changes: 10 additions & 10 deletions lib/services/datasets.js
Expand Up @@ -43,7 +43,7 @@ var Datasets = module.exports = makeService('MapboxDatasets');
Datasets.prototype.listDatasets = function(callback) {
invariant(typeof callback === 'function', 'callback must be a function');

var url = makeURL(this, constants.API_DATASET_DATASETS, { owner: this.user });
var url = makeURL(this, constants.API_DATASET_DATASETS, { owner: this.owner });

request(url, function(err, res) {
callback(err, res.body);
Expand Down Expand Up @@ -83,7 +83,7 @@ Datasets.prototype.createDataset = function(options, callback) {
invariant(typeof options === 'object', 'options must be an object');
invariant(typeof callback === 'function', 'callback must be a function');

var url = makeURL(this, constants.API_DATASET_DATASETS, { owner: this.user });
var url = makeURL(this, constants.API_DATASET_DATASETS, { owner: this.owner });

request
.post(url)
Expand Down Expand Up @@ -119,7 +119,7 @@ Datasets.prototype.readDataset = function(dataset, callback) {
invariant(typeof callback === 'function', 'callback must be a function');

var url = makeURL(this, constants.API_DATASET_DATASET, {
owner: this.user,
owner: this.owner,
dataset: dataset
});

Expand Down Expand Up @@ -160,7 +160,7 @@ Datasets.prototype.updateDataset = function(dataset, options, callback) {
invariant(!!options.name || !!options.description, 'options must include a name or a description');

var url = makeURL(this, constants.API_DATASET_DATASET, {
owner: this.user,
owner: this.owner,
dataset: dataset
});

Expand Down Expand Up @@ -190,7 +190,7 @@ Datasets.prototype.deleteDataset = function(dataset, callback) {
invariant(typeof callback === 'function', 'callback must be a function');

var url = makeURL(this, constants.API_DATASET_DATASET, {
owner: this.user,
owner: this.owner,
dataset: dataset
});

Expand Down Expand Up @@ -236,7 +236,7 @@ Datasets.prototype.listFeatures = function(dataset, callback) {
invariant(typeof callback === 'function', 'callback must be a function');

var url = makeURL(this, constants.API_DATASET_FEATURES, {
owner: this.user,
owner: this.owner,
dataset: dataset
});

Expand Down Expand Up @@ -326,7 +326,7 @@ Datasets.prototype.insertFeature = function(feature, dataset, callback) {
invariant(typeof id === 'string', 'The GeoJSON feature\'s id must be a string');

var url = makeURL(this, constants.API_DATASET_FEATURE, {
owner: this.user,
owner: this.owner,
dataset: dataset,
id: id
});
Expand Down Expand Up @@ -370,7 +370,7 @@ Datasets.prototype.readFeature = function(id, dataset, callback) {
invariant(typeof callback === 'function', 'callback must be a function');

var url = makeURL(this, constants.API_DATASET_FEATURE, {
owner: this.user,
owner: this.owner,
dataset: dataset,
id: id
});
Expand Down Expand Up @@ -400,7 +400,7 @@ Datasets.prototype.deleteFeature = function(id, dataset, callback) {
invariant(typeof callback === 'function', 'callback must be a function');

var url = makeURL(this, constants.API_DATASET_FEATURE, {
owner: this.user,
owner: this.owner,
dataset: dataset,
id: id
});
Expand Down Expand Up @@ -512,7 +512,7 @@ Datasets.prototype.bulkFeatureUpdate = function(update, dataset, callback) {
);

var url = makeURL(this, constants.API_DATASET_FEATURES, {
owner: this.user,
owner: this.owner,
dataset: dataset
});

Expand Down
4 changes: 2 additions & 2 deletions test/datasets.js
Expand Up @@ -35,7 +35,7 @@ test('DatasetClient', function(datasetClient) {
assert.ok(dataset.id, 'has id');
assert.notOk(dataset.name, 'no name');
assert.notOk(dataset.description, 'no description');
assert.equal(dataset.owner, client.user, 'has owner');
assert.equal(dataset.owner, client.owner, 'has owner');
testDatasets.push(dataset.id);
assert.end();
});
Expand All @@ -52,7 +52,7 @@ test('DatasetClient', function(datasetClient) {
assert.ok(dataset.id, 'has id');
assert.equal(dataset.name, 'test', 'has name');
assert.equal(dataset.description, 'for testing', 'has description');
assert.equal(dataset.owner, client.user, 'has owner');
assert.equal(dataset.owner, client.owner, 'has owner');
testDatasets.push(dataset.id);
assert.end();
});
Expand Down
8 changes: 4 additions & 4 deletions test/make_service.js
Expand Up @@ -64,19 +64,19 @@ test('make_service', function(t) {
assert.end();
});

t.test('sets user from account option', function(assert) {
t.test('sets owner from account option', function(assert) {
var TestService = makeService('Test');
var validToken = 'pk.eyJ1Ijoid29yYmx5IiwiYSI6ImQzMjFkZWRkN2IzNzc5M2MzZDgyNTIzZTRhM2E5MDE3In0.IIrNhFTaOiW-Ykw_J-yQbg';
var service = new TestService(validToken, { account: 'bambam' });
assert.equal(service.user, 'bambam', 'success');
assert.equal(service.owner, 'bambam', 'success');
assert.end();
});

t.test('sets user from access token', function(assert) {
t.test('sets owner from access token', function(assert) {
var TestService = makeService('Test');
var validToken = 'pk.eyJ1Ijoid29yYmx5IiwiYSI6ImQzMjFkZWRkN2IzNzc5M2MzZDgyNTIzZTRhM2E5MDE3In0.IIrNhFTaOiW-Ykw_J-yQbg';
var service = new TestService(validToken);
assert.equal(service.user, 'worbly', 'success');
assert.equal(service.owner, 'worbly', 'success');
assert.end();
});

Expand Down

0 comments on commit 3b9e1a0

Please sign in to comment.