added collection renaming

This commit is contained in:
Ritchie Martori
2012-03-27 09:32:49 -07:00
parent f78778a9b4
commit 64fd4210ce
2 changed files with 31 additions and 0 deletions

View File

@@ -20,6 +20,17 @@ module.exports =
, errs = []
;
end(function (req, res, next) {
if(!collectionPath) return next();
console.log('rename to', collectionPath.replace('/', ''));
collection.use(collectionPath).rename(collectionPath.replace('/', ''), function (err) {
next(err);
});
})
properties && Object.keys(properties).forEach(function (key) {
prop = properties[key];
rename = prop.$renameFrom;

View File

@@ -62,6 +62,26 @@ describe('Application Resource Types', function(){
})
})
describe('PUT /resources/<ObjectID>', function(){
it('should rename the resource collection', function(done) {
resources.get(function (e, all) {
var res = all[0];
res.path = '/tasks';
todos.post({title: 'foo'}, function () {
resources.use('/' + res._id).put(res, function (err, upd) {
unauthed.use('/tasks').get(function (ee, r) {
expect(r).to.exist;
client.use('/tasks').del(function () {
done(ee || e || err);
})
})
})
})
})
})
})
describe('PUT /resources/<ObjectID>', function(){
it('should rename change properties on any existing data', function(done) {
var exTodo = {title: 'feed fido', completed: true};