couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject fauxton commit: updated refs/heads/master to 9d16471
Date Tue, 26 Jan 2016 16:50:46 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master f6d85b4a4 -> 9d164711b


fix api url for doc editor

if the document was not created yet, the url pointed to
`undefined`

PR: #629
PR-URL: https://github.com/apache/couchdb-fauxton/pull/629
Reviewed-By: Benjamin Keen <ben.keen@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/9d164711
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/9d164711
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/9d164711

Branch: refs/heads/master
Commit: 9d164711bd893efec1cf7c8dd3619ddf4f5c4324
Parents: f6d85b4
Author: Robert Kowalski <robertkowalski@apache.org>
Authored: Tue Jan 26 14:28:43 2016 +0100
Committer: Robert Kowalski <robertkowalski@apache.org>
Committed: Tue Jan 26 17:50:26 2016 +0100

----------------------------------------------------------------------
 app/addons/documents/base.js                |  5 +++++
 app/addons/documents/routes-doc-editor.js   |  4 ++++
 app/addons/documents/shared-resources.js    |  1 +
 app/addons/documents/tests/resourcesSpec.js | 16 ++++++++++++++++
 4 files changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/9d164711/app/addons/documents/base.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/base.js b/app/addons/documents/base.js
index cb9b9d1..75620e5 100644
--- a/app/addons/documents/base.js
+++ b/app/addons/documents/base.js
@@ -96,6 +96,11 @@ function (app, FauxtonAPI, Documents) {
     },
 
     apiurl: function (database, doc) {
+      if (!doc) {
+        // api url for creating a doc with POST
+        return window.location.origin + '/' + database;
+      }
+
       return window.location.origin + '/' + database + '/' + doc;
     },
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/9d164711/app/addons/documents/routes-doc-editor.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/routes-doc-editor.js b/app/addons/documents/routes-doc-editor.js
index 81e6e00..8e5bedd 100644
--- a/app/addons/documents/routes-doc-editor.js
+++ b/app/addons/documents/routes-doc-editor.js
@@ -123,6 +123,10 @@ function (app, FauxtonAPI, Helpers, Documents, Databases, Actions, ReactComponen
       this.isNewDoc = true;
     },
 
+    apiUrl: function () {
+      return [this.doc.url('apiurl'), this.doc.documentation()];
+    },
+
     crumbs: function () {
       var previousPage = Helpers.getPreviousPageForDoc(this.database);
       return [

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/9d164711/app/addons/documents/shared-resources.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/shared-resources.js b/app/addons/documents/shared-resources.js
index fcf9293..1b0c1c0 100644
--- a/app/addons/documents/shared-resources.js
+++ b/app/addons/documents/shared-resources.js
@@ -26,6 +26,7 @@ define([
     documentation: function () {
       return FauxtonAPI.constants.DOC_URLS.GENERAL;
     },
+
     url: function (context) {
       if (context === undefined) {
         context = 'server';

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/9d164711/app/addons/documents/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/resourcesSpec.js b/app/addons/documents/tests/resourcesSpec.js
index e8b608d..7189fe9 100644
--- a/app/addons/documents/tests/resourcesSpec.js
+++ b/app/addons/documents/tests/resourcesSpec.js
@@ -68,6 +68,22 @@ define([
       });
       assert.notOk(res.id);
     });
+
+    it('can return the doc url, if id given', function () {
+      doc = new Models.Doc({_id: 'scholle'}, {
+        database: {id: 'blerg', safeID: function () { return this.id; }}
+      });
+
+      assert.ok(/\/blerg/.test(doc.url('apiurl')));
+    });
+
+    it('will return the API url to create a new doc, if no doc exists yet', function () {
+      doc = new Models.Doc({}, {
+        database: {id: 'blerg', safeID: function () { return this.id; }}
+      });
+
+      assert.ok(/\/blerg/.test(doc.url('apiurl')));
+    });
   });
 
   describe('MangoIndex', function () {


Mime
View raw message