Skip to content

Commit

Permalink
remove Layers.destroy, add Layer.destroy. cleanning layer in test end.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyll committed Jul 10, 2010
1 parent 2df47fb commit c6266f1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
24 changes: 10 additions & 14 deletions lib/pincaster/pincaster.js
Expand Up @@ -167,6 +167,16 @@ Layer.prototype.create = function(callback) {
.post('/api/1.0/layers/' + encodeURI(this.name) + '.json', {'content-type': 'application/x-www-form-urlencoded'})
}

/**
* Delete the layer.
* @param {Function} callback (err, ack) on operation complete.
*/
Layer.prototype.destroy = function(callback) {
new Query(this.pincaster)
.callback(callback)
.destroy('/api/1.0/layers/' + encodeURI(this.name) + '.json')
}

/**
* Layers list. Allow querys on layers info.
* @param {Pincaster} pincaster the server to use.
Expand Down Expand Up @@ -198,20 +208,6 @@ Layers.prototype.all = function(callback) {
.get('/api/1.0/layers/index.json')
}

/**
* Delete a layer from pincaster server.
* @param {String||Layer} name the layer's himself or his name to delete.
* @param {Function} callback (err, ack)
*/
Layers.prototype.destroy = function(name, callback) {
if(name instanceof Layer) {
name = name.name
}
new Query(this.pincaster)
.callback(callback)
.destroy('/api/1.0/layers/' + encodeURI(name) + '.json')
}

/**
* Defining a record.
* @param {String} key the id of this record.
Expand Down
2 changes: 1 addition & 1 deletion test/layer-test.js
Expand Up @@ -48,7 +48,7 @@ vows.describe('Layer').addBatch({
}).addBatch({
'when destroying': {
topic: function() {
layers.destroy(layer, this.callback)
layer.destroy(this.callback)
},
'is deleted': function (err, topic) {
assert.isNull(err)
Expand Down
10 changes: 10 additions & 0 deletions test/record-test.js
Expand Up @@ -62,5 +62,15 @@ vows.describe('Records').addBatch({
assert.deepEqual(content.properties, {update_field: "new value"})
}
}
}).addBatch({
'when deleting a layer': {
topic: function() {
layer2.destroy(this.callback)
},
'ack': function (err, content) {
assert.isNull(err)
assert.equal(content.status, 'deleted')
}
}
// todo test destroy layer.
}).export(module)

0 comments on commit c6266f1

Please sign in to comment.