Skip to content

Commit

Permalink
feat: notification-url for rename and destroy methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudinary-pkoniu committed Mar 19, 2024
1 parent 10835d8 commit e9e8fc3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ exports.destroy = function destroy(public_id, callback, options = {}) {
timestamp: utils.timestamp(),
type: options.type,
invalidate: options.invalidate,
public_id: public_id
public_id: public_id,
notification_url: options.notification_url
}
];
});
Expand All @@ -223,7 +224,8 @@ exports.rename = function rename(from_public_id, to_public_id, callback, options
invalidate: options.invalidate,
to_type: options.to_type,
context: options.context,
metadata: options.metadata
metadata: options.metadata,
notification_url: options.notification_url
}
];
});
Expand Down
12 changes: 12 additions & 0 deletions test/integration/api/uploader/uploader_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ describe("uploader", function () {
expect(renameResult).to.have.property('tags');
expect(renameResult).to.have.property('context');
});
it('should include notification_url in rename response if included in the request', async () => {
return helper.provideMockObjects(function (mockXHR, writeSpy, requestSpy) {
const renameResult = cloudinary.v2.uploader.rename('irrelevant', 'irrelevant', { notification_url: 'https://notification-url.com' });
sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher('notification_url', 'https://notification-url.com')));
});
});
return context(":invalidate", function () {
var spy, xhr;
spy = void 0;
Expand Down Expand Up @@ -228,6 +234,12 @@ describe("uploader", function () {
expect(error).to.be.ok();
});
});
it('should pass notification_url', async () => {
return helper.provideMockObjects(function (mockXHR, writeSpy, requestSpy) {
const renameResult = cloudinary.v2.uploader.destroy('irrelevant', { notification_url: 'https://notification-url.com' });
sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher('notification_url', 'https://notification-url.com')));
});
});
});
it("should support `async` option in explicit api", function () {
return cloudinary.v2.uploader.explicit("sample", {
Expand Down

0 comments on commit e9e8fc3

Please sign in to comment.