Skip to content

Commit

Permalink
add job#remove method
Browse files Browse the repository at this point in the history
  • Loading branch information
rschmukler committed Mar 9, 2014
1 parent 879d39f commit b188139
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ Job.prototype.save = function(cb) {
return this;
};

Job.prototype.remove = function(cb) {
this.agenda._db.remove({_id: this.attrs._id}, cb);
};

function parsePriority(priority) {
var priorityMap = {
lowest: -20,
Expand Down
14 changes: 14 additions & 0 deletions test/agenda.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,20 @@ describe('Job', function() {

});

describe.only('remove', function() {
it('removes the job', function(done) {
var job = new Job({agenda: jobs, name: 'removed job'});
job.save(function() {
job.remove(function() {
mongo.collection('agendaJobs').find({_id: job.attrs._id}).toArray(function(err, j) {
expect(j).to.have.length(0);
done();
});
});
});
});
});

describe('run', function() {
var job,
definitions = jobs._definitions;
Expand Down

0 comments on commit b188139

Please sign in to comment.