You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/10/03 18:50:44 UTC

[GitHub] Antonio-Maranhao closed pull request #1131: Fix - Error is shown when enabling CORS

Antonio-Maranhao closed pull request #1131: Fix - Error is shown when enabling CORS 
URL: https://github.com/apache/couchdb-fauxton/pull/1131
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/app/core/__tests__/ajax.test.js b/app/core/__tests__/ajax.test.js
index 5ffc82e5a..c16aa2e8c 100644
--- a/app/core/__tests__/ajax.test.js
+++ b/app/core/__tests__/ajax.test.js
@@ -140,4 +140,74 @@ describe('Fauxton Ajax', () => {
         assert.ok(resp.ok);
       });
   });
+
+  describe('POST with falsy values as the body', () => {
+    const successResponse = {
+      status: 200,
+      body: {
+        ok: true
+      }
+    };
+    it('accepts empty string', () => {
+      fetchMock.postOnce('/testing', successResponse);
+      return post('/testing', '')
+        .then(resp =>{
+          assert.ok(resp.ok);
+          assert.ok(fetchMock.lastOptions().body === '""');
+        });
+    });
+
+    it('accepts zero', () => {
+      fetchMock.postOnce('/testing', successResponse);
+      return post('/testing', 0)
+        .then(resp =>{
+          assert.ok(resp.ok);
+          assert.ok(fetchMock.lastOptions().body === '0');
+        });
+    });
+
+    it('accepts false', () => {
+      fetchMock.postOnce('/testing', successResponse);
+      return post('/testing', false)
+        .then(resp =>{
+          assert.ok(resp.ok);
+          assert.ok(fetchMock.lastOptions().body === 'false');
+        });
+    });
+  });
+
+  describe('PUT with falsy values as the body', () => {
+    const successResponse = {
+      status: 200,
+      body: {
+        ok: true
+      }
+    };
+    it('accepts empty string', () => {
+      fetchMock.putOnce('/testing', successResponse);
+      return put('/testing', '')
+        .then(resp =>{
+          assert.ok(resp.ok);
+          assert.ok(fetchMock.lastOptions().body === '""');
+        });
+    });
+
+    it('accepts zero', () => {
+      fetchMock.putOnce('/testing', successResponse);
+      return put('/testing', 0)
+        .then(resp =>{
+          assert.ok(resp.ok);
+          assert.ok(fetchMock.lastOptions().body === '0');
+        });
+    });
+
+    it('accepts false', () => {
+      fetchMock.putOnce('/testing', successResponse);
+      return put('/testing', false)
+        .then(resp =>{
+          assert.ok(resp.ok);
+          assert.ok(fetchMock.lastOptions().body === 'false');
+        });
+    });
+  });
 });
diff --git a/app/core/ajax.js b/app/core/ajax.js
index 07fd094e3..305d8dc1f 100644
--- a/app/core/ajax.js
+++ b/app/core/ajax.js
@@ -81,7 +81,7 @@ export const deleteRequest = (url, opts = {}) => {
  * @return {Promise} A promise with the request's response
  */
 export const post = (url, body, opts = {}) => {
-  if (body) {
+  if (typeof body !== 'undefined') {
     if (opts.rawBody)
       opts.body = body;
     else
@@ -101,7 +101,7 @@ export const post = (url, body, opts = {}) => {
  * @return {Promise} A promise with the request's response
  */
 export const put = (url, body, opts = {}) => {
-  if (body) {
+  if (typeof body !== 'undefined') {
     if (opts.rawBody)
       opts.body = body;
     else


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services