Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2019-06-18 11:22:06 +0300
committer🤖 GitLab Bot 🤖 <gitlab-bot@gitlab.com>2019-06-18 17:24:45 +0300
commit34e946372896c0f129eefd8577d10e400a4362d6 (patch)
tree4ca0fbe881c4b8519b4f116f4e0d98fb4e986e66 /spec
parentb60a6e4830bea094016f1f906c69c575002aee0d (diff)
Merge branch '59023-fix-web-ide-creating-branches-off-new-commits' into 'master'
Fix IDE commit to use start_ref See merge request gitlab-org/gitlab-ce!29769 (cherry picked from commit c4efc7b53aad3be5109c4256f3438f908e180c20) 894ad6f6 Fix IDE commit to use start_ref
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/ide/services/index_spec.js55
-rw-r--r--spec/javascripts/ide/stores/modules/commit/actions_spec.js18
-rw-r--r--spec/javascripts/ide/stores/utils_spec.js4
3 files changed, 70 insertions, 7 deletions
diff --git a/spec/frontend/ide/services/index_spec.js b/spec/frontend/ide/services/index_spec.js
new file mode 100644
index 00000000000..499fa8fc012
--- /dev/null
+++ b/spec/frontend/ide/services/index_spec.js
@@ -0,0 +1,55 @@
+import services from '~/ide/services';
+import Api from '~/api';
+
+jest.mock('~/api');
+
+const TEST_PROJECT_ID = 'alice/wonderland';
+const TEST_BRANCH = 'master-patch-123';
+const TEST_COMMIT_SHA = '123456789';
+
+describe('IDE services', () => {
+ describe('commit', () => {
+ let payload;
+
+ beforeEach(() => {
+ payload = {
+ branch: TEST_BRANCH,
+ commit_message: 'Hello world',
+ actions: [],
+ start_sha: undefined,
+ };
+
+ Api.createBranch.mockReturnValue(Promise.resolve());
+ Api.commitMultiple.mockReturnValue(Promise.resolve());
+ });
+
+ describe.each`
+ startSha | shouldCreateBranch
+ ${undefined} | ${false}
+ ${TEST_COMMIT_SHA} | ${true}
+ `('when start_sha is $startSha', ({ startSha, shouldCreateBranch }) => {
+ beforeEach(() => {
+ payload.start_sha = startSha;
+
+ return services.commit(TEST_PROJECT_ID, payload);
+ });
+
+ if (shouldCreateBranch) {
+ it('should create branch', () => {
+ expect(Api.createBranch).toHaveBeenCalledWith(TEST_PROJECT_ID, {
+ ref: TEST_COMMIT_SHA,
+ branch: TEST_BRANCH,
+ });
+ });
+ } else {
+ it('should not create branch', () => {
+ expect(Api.createBranch).not.toHaveBeenCalled();
+ });
+ }
+
+ it('should commit', () => {
+ expect(Api.commitMultiple).toHaveBeenCalledWith(TEST_PROJECT_ID, payload);
+ });
+ });
+ });
+});
diff --git a/spec/javascripts/ide/stores/modules/commit/actions_spec.js b/spec/javascripts/ide/stores/modules/commit/actions_spec.js
index 5f7272311c8..8a3c132972e 100644
--- a/spec/javascripts/ide/stores/modules/commit/actions_spec.js
+++ b/spec/javascripts/ide/stores/modules/commit/actions_spec.js
@@ -6,9 +6,11 @@ import eventHub from '~/ide/eventhub';
import consts from '~/ide/stores/modules/commit/constants';
import * as mutationTypes from '~/ide/stores/modules/commit/mutation_types';
import * as actions from '~/ide/stores/modules/commit/actions';
-import testAction from '../../../../helpers/vuex_action_helper';
import { commitActionTypes } from '~/ide/constants';
import { resetStore, file } from 'spec/ide/helpers';
+import testAction from '../../../../helpers/vuex_action_helper';
+
+const TEST_COMMIT_SHA = '123456789';
describe('IDE commit module actions', () => {
beforeEach(() => {
@@ -139,6 +141,9 @@ describe('IDE commit module actions', () => {
branches: {
master: {
workingReference: '',
+ commit: {
+ short_id: TEST_COMMIT_SHA,
+ },
},
},
};
@@ -239,6 +244,9 @@ describe('IDE commit module actions', () => {
branches: {
master: {
workingReference: '1',
+ commit: {
+ short_id: TEST_COMMIT_SHA,
+ },
},
},
};
@@ -247,7 +255,7 @@ describe('IDE commit module actions', () => {
...file('changed'),
type: 'blob',
active: true,
- lastCommitSha: '123456789',
+ lastCommitSha: TEST_COMMIT_SHA,
};
store.state.stagedFiles.push(f);
store.state.changedFiles = [
@@ -307,7 +315,7 @@ describe('IDE commit module actions', () => {
previous_path: undefined,
},
],
- start_branch: 'master',
+ start_sha: TEST_COMMIT_SHA,
});
done();
@@ -330,11 +338,11 @@ describe('IDE commit module actions', () => {
file_path: jasmine.anything(),
content: undefined,
encoding: jasmine.anything(),
- last_commit_id: '123456789',
+ last_commit_id: TEST_COMMIT_SHA,
previous_path: undefined,
},
],
- start_branch: undefined,
+ start_sha: undefined,
});
done();
diff --git a/spec/javascripts/ide/stores/utils_spec.js b/spec/javascripts/ide/stores/utils_spec.js
index debe1c4acee..e3bf6d40245 100644
--- a/spec/javascripts/ide/stores/utils_spec.js
+++ b/spec/javascripts/ide/stores/utils_spec.js
@@ -132,7 +132,7 @@ describe('Multi-file store utils', () => {
previous_path: undefined,
},
],
- start_branch: undefined,
+ start_sha: undefined,
});
});
@@ -187,7 +187,7 @@ describe('Multi-file store utils', () => {
previous_path: undefined,
},
],
- start_branch: undefined,
+ start_sha: undefined,
});
});
});