summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMarin Jankovski <marin@gitlab.com>2019-06-26 13:45:43 +0000
committerMarin Jankovski <marin@gitlab.com>2019-06-26 13:45:43 +0000
commitb3d31fcfb94e42b5896996dbc143d5387159587e (patch)
tree8bff0c806f2d601ca5572e477368f03b42a218e2 /spec
parent6119c60a959c795d3216066aeb22c314fb8786e0 (diff)
parent7ca2b5a180b230f7bd11e8d2a46bdc83e7ee6f07 (diff)
downloadgitlab-ce-b3d31fcfb94e42b5896996dbc143d5387159587e.tar.gz
Merge branch '11-11-stable-patch-4' into '11-11-stable'
Prepare 11.11.4 release See merge request gitlab-org/gitlab-ce!30069
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/import/fogbugz_controller_spec.rb38
-rw-r--r--spec/frontend/ide/services/index_spec.js55
-rw-r--r--spec/javascripts/ide/stores/modules/commit/actions_spec.js16
-rw-r--r--spec/javascripts/ide/stores/utils_spec.js4
4 files changed, 107 insertions, 6 deletions
diff --git a/spec/controllers/import/fogbugz_controller_spec.rb b/spec/controllers/import/fogbugz_controller_spec.rb
index f1e0923f316..f7c813576aa 100644
--- a/spec/controllers/import/fogbugz_controller_spec.rb
+++ b/spec/controllers/import/fogbugz_controller_spec.rb
@@ -11,6 +11,44 @@ describe Import::FogbugzController do
sign_in(user)
end
+ describe 'POST #callback' do
+ let(:token) { FFaker::Lorem.characters(8) }
+ let(:uri) { 'https://example.com' }
+ let(:xml_response) { %Q(<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><token><![CDATA[#{token}]]></token></response>) }
+
+ it 'attempts to contact Fogbugz server' do
+ stub_request(:post, "https://example.com/api.asp").to_return(status: 200, body: xml_response, headers: {})
+
+ post :callback, params: { uri: uri, email: 'test@example.com', password: 'mypassword' }
+
+ expect(session[:fogbugz_token]).to eq(token)
+ expect(session[:fogbugz_uri]).to eq(uri)
+ expect(response).to redirect_to(new_user_map_import_fogbugz_path)
+ end
+ end
+
+ describe 'POST #create_user_map' do
+ let(:user_map) do
+ {
+ "2" => {
+ "name" => "Test User",
+ "email" => "testuser@example.com",
+ "gitlab_user" => "3"
+ }
+ }
+ end
+
+ it 'stores the user map in the session' do
+ client = double(user_map: {})
+ expect(controller).to receive(:client).and_return(client)
+
+ post :create_user_map, params: { users: user_map }
+
+ expect(session[:fogbugz_user_map]).to eq(user_map)
+ expect(response).to redirect_to(status_import_fogbugz_path)
+ end
+ end
+
describe 'GET status' do
before do
@repo = OpenStruct.new(name: 'vim')
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 cdeb9b4b896..39902157441 100644
--- a/spec/javascripts/ide/stores/modules/commit/actions_spec.js
+++ b/spec/javascripts/ide/stores/modules/commit/actions_spec.js
@@ -7,6 +7,8 @@ import consts from '~/ide/stores/modules/commit/constants';
import { commitActionTypes } from '~/ide/constants';
import { resetStore, file } from 'spec/ide/helpers';
+const TEST_COMMIT_SHA = '123456789';
+
describe('IDE commit module actions', () => {
beforeEach(() => {
spyOn(router, 'push');
@@ -136,6 +138,9 @@ describe('IDE commit module actions', () => {
branches: {
master: {
workingReference: '',
+ commit: {
+ short_id: TEST_COMMIT_SHA,
+ },
},
},
};
@@ -236,6 +241,9 @@ describe('IDE commit module actions', () => {
branches: {
master: {
workingReference: '1',
+ commit: {
+ short_id: TEST_COMMIT_SHA,
+ },
},
},
};
@@ -244,7 +252,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 = [
@@ -303,7 +311,7 @@ describe('IDE commit module actions', () => {
previous_path: undefined,
},
],
- start_branch: 'master',
+ start_sha: TEST_COMMIT_SHA,
});
done();
@@ -326,11 +334,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,
});
});
});