popojargo closed pull request #1094: Allow to resolve conflicts of design
documents
URL: https://github.com/apache/couchdb-fauxton/pull/1094
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/addons/documents/routes-doc-editor.js
b/app/addons/documents/routes-doc-editor.js
index 3701666b8..aa0971093 100644
--- a/app/addons/documents/routes-doc-editor.js
+++ b/app/addons/documents/routes-doc-editor.js
@@ -35,6 +35,7 @@ const DocEditorRouteObject = FauxtonAPI.RouteObject.extend({
routes: {
'database/:database/:doc/conflicts': 'revisionBrowser',
'database/:database/:doc/code_editor': 'codeEditor',
+ 'database/:database/_design/:ddoc/conflicts': 'revBrowserForDesignDoc',
'database/:database/_design/:ddoc': 'showDesignDoc',
'database/:database/_local/:doc': 'showLocalDoc',
'database/:database/:doc': 'codeEditor',
@@ -58,6 +59,10 @@ const DocEditorRouteObject = FauxtonAPI.RouteObject.extend({
/>;
},
+ revBrowserForDesignDoc: function(databaseName, ddoc) {
+ return this.revisionBrowser(databaseName, '_design/' + ddoc);
+ },
+
codeEditor: function (databaseName, docId) {
const backLink = FauxtonAPI.urls('allDocs', 'app',
FauxtonAPI.url.encode(databaseName));
diff --git a/app/addons/documents/tests/nightwatch/revBrowser.js
b/app/addons/documents/tests/nightwatch/revBrowser.js
index 9674c7932..7d19a7056 100644
--- a/app/addons/documents/tests/nightwatch/revBrowser.js
+++ b/app/addons/documents/tests/nightwatch/revBrowser.js
@@ -57,6 +57,52 @@ module.exports = {
this.verify.ok(result.value.indexOf('"color": "white"') !== -1, 'check
if doc version was promoted');
})
+ .end();
+ },
+ 'is able to show two design docs next to each other, and diff them' :
function (client) {
+ /*jshint multistr: true */
+ const waitTime = client.globals.maxWaitTime;
+ const newDatabaseName = 'animaldb';
+ const baseUrl = client.globals.test_settings.launch_url;
+
+ client
+ .createAnimalDb()
+ .checkForDocumentCreated('_design/animals', null, newDatabaseName)
+
+ .loginToGUI()
+ .url(baseUrl + '/#/database/' + newDatabaseName + '/_design/animals')
+
+ .clickWhenVisible('button.conflicts')
+
+ .waitForElementVisible('.revision-diff-area', waitTime, false)
+
+ .assert.containsText('.revision-diff-area', '"black & white"')
+ .assert.containsText('.revision-diff-area', '"white"')
+
+ .clickWhenVisible('.two-sides-toggle-button button:last-child')
+
+ .waitForElementVisible('.revision-split-area', waitTime, false)
+
+ .assert.containsText('.revision-split-area [data-id="ours"]', '"black &
white"')
+ .assert.containsText('.revision-split-area [data-id="theirs"]',
'"white"')
+
+
+ .clickWhenVisible('[data-id="button-select-theirs"]')
+ .clickWhenVisible('.modal-footer input[type="checkbox"]')
+ .clickWhenVisible('.modal-footer button.btn-danger')
+ .clickWhenVisible('.fonticon-json')
+
+ .clickWhenVisible('[data-id="_design/animals"] a')
+
+ .waitForElementVisible('.panel-section', waitTime, false)
+ .assert.elementNotPresent('button.conflicts')
+
+ .url(baseUrl + '/#/database/' + newDatabaseName +
'?include_docs=true&conflicts=true')
+
+ .getText('body', function (result) {
+ this.verify.ok(result.value.indexOf('"color": "white"') !== -1, 'check
if doc version was promoted');
+ })
+
.end();
}
};
diff --git a/test/animal-db.json b/test/animal-db.json
index 19e3ff5c1..a8d7ad70c 100644
--- a/test/animal-db.json
+++ b/test/animal-db.json
@@ -9,5 +9,6 @@
{"_id":"llama","min_weight":130,"max_weight":200,"min_length":1.7,"max_length":1.8,"latin_name":"Lama
glama","wiki_page":"http://en.wikipedia.org/wiki/Llama","class":"mammal","diet":"herbivore"},
{"_id":"panda","wiki_page":"http://en.wikipedia.org/wiki/Panda","min_weight":75,"max_weight":115,"min_length":1.2,"max_length":1.8,"class":"mammal","diet":"carnivore"},
{"_id":"snipe","min_weight":0.08,"max_weight":0.14,"min_length":0.25,"max_length":0.27,"latin_name":"Gallinago
gallinago","wiki_page":"http://en.wikipedia.org/wiki/Common_Snipe","class":"bird","diet":"omnivore"},
-{"_id":"zebra","wiki_page":"http://en.wikipedia.org/wiki/Plains_zebra","min_length":2,"max_length":2.5,"min_weight":175,"max_weight":387,"class":"mammal","diet":"herbivore"}
+{"_id":"zebra","wiki_page":"http://en.wikipedia.org/wiki/Plains_zebra","min_length":2,"max_length":2.5,"min_weight":175,"max_weight":387,"class":"mammal","diet":"herbivore"},
+{"_id":"_design/animals",
"language":"javascript","views":{"by-latin-name":{"map":"function(doc){if(doc.latin_name)emit(doc.latin_name);}"}}}
]
diff --git a/test/create-animal-db.js b/test/create-animal-db.js
index c128c42f7..1e5205a9d 100644
--- a/test/create-animal-db.js
+++ b/test/create-animal-db.js
@@ -3,8 +3,6 @@ const async = require('async');
const animals = require('../test/animal-db.json');
-const conflictingDoc = 'zebra';
-
module.exports = createAnimalDb;
function createAnimalDb (url, cb) {
@@ -65,7 +63,10 @@ function createAnimalDb (url, cb) {
replicate(`${url}/animaldb`, `${url}/animaldb-copy-2`, true, cb);
},
(cb) => {
- alterDocs(cb);
+ alterZebraDocs(cb);
+ },
+ (cb) => {
+ alterAnimalDesignDoc(cb)
},
(cb) => {
replicate(`${url}/animaldb-copy`, `${url}/animaldb`, false, cb);
@@ -125,27 +126,27 @@ function createAnimalDb (url, cb) {
});
}
- function getRev (db, cb) {
+ function getRev (db, id, cb) {
request({
- uri: `${url}/${db}/${conflictingDoc}`,
+ uri: `${url}/${db}/${id}`,
json: true
}, (err, res, body) => {
cb(null, body._rev);
});
}
- function updateDoc (db, data, cb) {
+ function updateDoc (db, id, data, cb) {
- getRev(db, (err, rev) => {
- alterDoc(db, data, rev, cb);
+ getRev(db, id, (err, rev) => {
+ alterDoc(db,id, data, rev, cb);
});
}
- function alterDoc (db, data, rev, cb) {
+ function alterDoc (db, id, data, rev, cb) {
data._rev = rev;
request({
- uri: `${url}/${db}/${conflictingDoc}`,
+ uri: `${url}/${db}/${id}`,
json: true,
method: 'PUT',
body: data
@@ -154,20 +155,34 @@ function createAnimalDb (url, cb) {
});
}
- function alterDocs (cb) {
+ function alterZebraDocs (cb) {
- updateDoc('animaldb', {
+ updateDoc('animaldb','zebra', {
color: 'black & white'
}, () => {
-
- updateDoc('animaldb-copy', {
+ updateDoc('animaldb-copy', 'zebra', {
color: 'white'
}, () => {
- updateDoc('animaldb-copy-2', {
+ updateDoc('animaldb-copy-2', 'zebra', {
color: 'green'
}, cb);
});
});
}
+ function alterAnimalDesignDoc (cb) {
+
+ updateDoc('animaldb','_design/animals', {
+ color: 'black & white'
+ }, () => {
+ updateDoc('animaldb-copy', '_design/animals', {
+ color: 'white'
+ }, () => {
+ updateDoc('animaldb-copy-2', '_design/animals', {
+ color: 'green'
+ }, cb);
+ });
+ });
+ }
+
}
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services