nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: auth0/node-auth0
Pull request #638 (2021-07-26 17:20:13)

Fix updateCustomTextByLanguage
Fixes updateCustomTextByLanguage, previously the payload was being added to the url and not the body fo the request.  Test included



Patch:
diff --git a/src/management/PromptsManager.js b/src/management/PromptsManager.js
index 78d0984ef..8065002f6 100644
--- a/src/management/PromptsManager.js
+++ b/src/management/PromptsManager.js
@@ -187,6 +187,7 @@ PromptsManager.prototype.getCustomTextByLanguage = function(params, cb) {
  */
 PromptsManager.prototype.updateCustomTextByLanguage = function(params, cb) {
   params = params || {};
+  options = {};
 
   if (!params.prompt || typeof params.prompt !== 'string') {
     throw new ArgumentError('The prompt parameter must be a string');
@@ -200,11 +201,14 @@ PromptsManager.prototype.updateCustomTextByLanguage = function(params, cb) {
     throw new ArgumentError('The body parameter must be an object');
   }
 
+  options.prompt = params.prompt;
+  options.language = params.language;
+
   if (cb && cb instanceof Function) {
-    return this.customTextByLanguage.update(params, params.body, cb);
+    return this.customTextByLanguage.update(options, params.body, cb);
   }
 
-  return this.customTextByLanguage.update(params, params.body);
+  return this.customTextByLanguage.update(options, params.body);
 };
 
 module.exports = PromptsManager;


Test patch:
diff --git a/test/management/prompts.tests.js b/test/management/prompts.tests.js
index a8a8c5292..14543f800 100644
--- a/test/management/prompts.tests.js
+++ b/test/management/prompts.tests.js
@@ -304,7 +304,7 @@ describe('PromptsManager', function() {
     var params = {
       prompt: 'test',
       language: 'english',
-      body: {}
+      body: { login: { title: 'Hello!' } }
     };
 
     beforeEach(function() {
@@ -365,7 +365,7 @@ describe('PromptsManager', function() {
       });
     });
 
-    it('shoushould perform a GET request to /api/v2/prompts/test/custom-text/english', function(done) {
+    it('should perform a PUT request to /api/v2/prompts/test/custom-text/english', function(done) {
       var request = this.request;
 
       this.prompts.updateCustomTextByLanguage(params).then(function() {
@@ -388,5 +388,22 @@ describe('PromptsManager', function() {
         done();
       });
     });
+
+    it('should send the payload to the body', function(done) {
+      nock.cleanAll();
+
+      var request = nock(API_URL)
+        .put(
+          '/prompts/test/custom-text/english',
+          body => body && body.login && body.login.title === 'Hello!'
+        )
+        .reply(200);
+
+      this.prompts.updateCustomTextByLanguage(params).then(function() {
+        expect(request.isDone()).to.be.true;
+
+        done();
+      });
+    });
   });
 });