summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Mishunov <dmishunov@gitlab.com>2019-03-26 16:23:15 +0100
committerDenys Mishunov <dmishunov@gitlab.com>2019-04-04 09:05:50 +0200
commitf6a038b38ae6c256fb9d1f1cbe184b0d8bbb5fde (patch)
treefcaf76fdc49cea23edff1a8bfcf11d11b67d57df
parentd0a0d3d3d5043d1497a5cd42e6c6bc073f6a5b58 (diff)
downloadgitlab-ce-f6a038b38ae6c256fb9d1f1cbe184b0d8bbb5fde.tar.gz
Create a new file if URL references non-existent one
-rw-r--r--app/assets/javascripts/ide/stores/actions/project.js5
-rw-r--r--spec/javascripts/ide/stores/actions/project_spec.js17
2 files changed, 22 insertions, 0 deletions
diff --git a/app/assets/javascripts/ide/stores/actions/project.js b/app/assets/javascripts/ide/stores/actions/project.js
index 06ed5c0b572..4b10d148ebf 100644
--- a/app/assets/javascripts/ide/stores/actions/project.js
+++ b/app/assets/javascripts/ide/stores/actions/project.js
@@ -147,6 +147,11 @@ export const openBranch = ({ dispatch, state }, { projectId, branchId, basePath
if (treeEntry) {
dispatch('handleTreeEntryAction', treeEntry);
+ } else {
+ dispatch('createTempEntry', {
+ name: path,
+ type: 'blob',
+ });
}
}
})
diff --git a/spec/javascripts/ide/stores/actions/project_spec.js b/spec/javascripts/ide/stores/actions/project_spec.js
index 7b0963713fb..cd519eaed7c 100644
--- a/spec/javascripts/ide/stores/actions/project_spec.js
+++ b/spec/javascripts/ide/stores/actions/project_spec.js
@@ -279,5 +279,22 @@ describe('IDE store project actions', () => {
.then(done)
.catch(done.fail);
});
+
+ it('creates a new file supplied via URL if the file does not exist yet', done => {
+ openBranch(store, { ...branch, basePath: 'not-existent.md' })
+ .then(() => {
+ expect(store.dispatch).not.toHaveBeenCalledWith(
+ 'handleTreeEntryAction',
+ jasmine.anything(),
+ );
+
+ expect(store.dispatch).toHaveBeenCalledWith('createTempEntry', {
+ name: 'not-existent.md',
+ type: 'blob',
+ });
+ })
+ .then(done)
+ .catch(done.fail);
+ });
});
});