couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From michel...@apache.org
Subject fauxton commit: updated refs/heads/master to 2bd9115
Date Thu, 12 Nov 2015 23:04:53 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master c90f22baa -> 2bd911539


Change URL for attachments


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

Branch: refs/heads/master
Commit: 2bd91153943bb50390c3a21dd7b89017ad207fd9
Parents: c90f22b
Author: Michelle Phung <michellep@apache.org>
Authored: Tue Nov 3 17:02:37 2015 -0500
Committer: Michelle Phung <michellep@apache.org>
Committed: Thu Nov 12 16:32:06 2015 -0500

----------------------------------------------------------------------
 app/addons/documents/base.js                    |  3 +++
 .../documents/doc-editor/components.react.jsx   |  6 +++--
 .../tests/doc-editor.componentsSpec.react.jsx   | 26 ++++++++++++++++----
 3 files changed, 28 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/2bd91153/app/addons/documents/base.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/base.js b/app/addons/documents/base.js
index df2478d..3dd82c0 100644
--- a/app/addons/documents/base.js
+++ b/app/addons/documents/base.js
@@ -75,6 +75,9 @@ function (app, FauxtonAPI, Documents) {
     },
 
     attachment: function (database, doc, filename, query) {
+      if (_.isUndefined(query)) {
+        query = '';
+      }
       return app.host + '/' + database + '/' + doc + '/' + filename + query;
     },
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/2bd91153/app/addons/documents/doc-editor/components.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/documents/doc-editor/components.react.jsx b/app/addons/documents/doc-editor/components.react.jsx
index bff69eb..376ef30 100644
--- a/app/addons/documents/doc-editor/components.react.jsx
+++ b/app/addons/documents/doc-editor/components.react.jsx
@@ -198,9 +198,11 @@ define([
     },
 
     getAttachmentList: function () {
-      var docBaseURL = this.props.doc.url();
+      var db = this.props.doc.database.get('id');
+      var doc = this.props.doc.get('_id');
+
       return _.map(this.props.doc.get('_attachments'), function (item, filename) {
-        var url = docBaseURL + '/' + app.utils.safeURLName(filename);
+        var url = FauxtonAPI.urls('document', 'attachment', db, doc, app.utils.safeURLName(filename));
         return (
           <li key={filename}>
             <a href={url} target="_blank" data-bypass="true"> <strong>{filename}</strong>
-

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/2bd91153/app/addons/documents/doc-editor/tests/doc-editor.componentsSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/documents/doc-editor/tests/doc-editor.componentsSpec.react.jsx b/app/addons/documents/doc-editor/tests/doc-editor.componentsSpec.react.jsx
index c8d3d83..eeaf2a2 100644
--- a/app/addons/documents/doc-editor/tests/doc-editor.componentsSpec.react.jsx
+++ b/app/addons/documents/doc-editor/tests/doc-editor.componentsSpec.react.jsx
@@ -19,8 +19,9 @@ define([
   'addons/documents/doc-editor/stores',
   'addons/documents/doc-editor/actions',
   'addons/documents/doc-editor/actiontypes',
+  'addons/databases/base',
   'testUtils'
-], function (app, FauxtonAPI, React, Documents, Components, Stores, Actions, ActionTypes,
utils) {
+], function (app, FauxtonAPI, React, Documents, Components, Stores, Actions, ActionTypes,
Databases, utils) {
   FauxtonAPI.router = new FauxtonAPI.Router([]);
 
   var assert = utils.assert;
@@ -54,10 +55,7 @@ define([
     }
   };
 
-  var database = {
-    id: 'id',
-    safeID: function () { return 'id'; }
-  };
+  var database = new Databases.Model({ id: 'id' });
 
 
   describe('DocEditorController', function () {
@@ -132,6 +130,24 @@ define([
       assert.equal($(el.getDOMNode()).find('.view-attachments-section .dropdown-menu li').length,
2);
     });
 
+    it('view attachments dropdown contains correct urls', function () {
+      var el = TestUtils.renderIntoDocument(<Components.DocEditorController database={database}
/>, container);
+
+      var doc = new Documents.Doc(docWithAttachmentsJSON, { database: database });
+      FauxtonAPI.dispatch({
+        type: ActionTypes.DOC_LOADED,
+        options: {
+          doc: doc
+        }
+      });
+
+      var attachmentNode = $(el.getDOMNode()).find('.view-attachments-section .dropdown-menu
li')[0];
+      var attachmentURLactual = $(attachmentNode).find('a').attr('href');
+
+      assert.equal(attachmentURLactual, "../../id/_design/test-doc/one.png");
+    });
+
+
     it('setting deleteDocModal=true in store shows modal', function () {
       var el = TestUtils.renderIntoDocument(<Components.DocEditorController database={database}
/>, container);
       var doc = new Documents.Doc(docWithAttachmentsJSON, { database: database });


Mime
View raw message