summaryrefslogtreecommitdiff
path: root/spec/controllers/import
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-07-08 07:38:07 -0700
committerStan Hu <stanhu@gmail.com>2018-07-08 07:38:07 -0700
commit24ac81cca62a18b102b3414d97541bdf23a31f2d (patch)
tree19593e84617a7e1722d5acbc3859438af4cc999c /spec/controllers/import
parentb3deab852bcbfe1fd86475d2881cd328c5374b05 (diff)
downloadgitlab-ce-24ac81cca62a18b102b3414d97541bdf23a31f2d.tar.gz
Add initial specs for app/controllers/import/bitbucket_server_controller.rb
Diffstat (limited to 'spec/controllers/import')
-rw-r--r--spec/controllers/import/bitbucket_server_controller_spec.rb77
1 files changed, 77 insertions, 0 deletions
diff --git a/spec/controllers/import/bitbucket_server_controller_spec.rb b/spec/controllers/import/bitbucket_server_controller_spec.rb
new file mode 100644
index 00000000000..1333633b877
--- /dev/null
+++ b/spec/controllers/import/bitbucket_server_controller_spec.rb
@@ -0,0 +1,77 @@
+require 'spec_helper'
+
+describe Import::BitbucketServerController do
+ let(:user) { create(:user) }
+ let(:project_key) { 'test-project' }
+ let(:repo_slug) { 'some-repo' }
+
+ def assign_session_tokens
+ session[:bitbucket_server_url] = 'http://localhost:7990'
+ session[:bitbucket_server_username] = 'bitbucket'
+ session[:bitbucket_server_personal_access_token] = 'some-token'
+ end
+
+ before do
+ sign_in(user)
+ allow(controller).to receive(:bitbucket_server_import_enabled?).and_return(true)
+ end
+
+ describe 'GET new' do
+ render_views
+
+ it 'shows the input form' do
+ get :new
+
+ expect(response.body).to have_text('Bitbucket Server URL')
+ end
+ end
+
+ describe 'POST create' do
+ before do
+ assign_session_tokens
+ end
+
+ set(:project) { create(:project) }
+
+ it 'returns the new project' do
+ client = instance_double(BitbucketServer::Client)
+ allow(Gitlab::BitbucketServerImport::ProjectCreator)
+ .to receive(:new).with(project_key, repo_slug, anything, 'my-project', user.namespace, user, anything)
+ .and_return(double(execute: project))
+ repo = double(name: 'my-project')
+ expect(client).to receive(:repo).with(project_key, repo_slug).and_return(repo)
+ expect(controller).to receive(:bitbucket_client).and_return(client)
+
+ post :create, project: project_key, repository: repo_slug, format: :json
+
+ expect(response).to have_gitlab_http_status(200)
+ end
+
+ it 'returns an error when an invalid project key is used' do
+ end
+
+ it 'returns an error when an invalid repository slug is used' do
+ end
+
+ it 'returns an error when the project cannot be saved' do
+ end
+
+ it "returns an error when the server can't be contacted" do
+ end
+ end
+
+ describe 'POST configure' do
+ it 'sets the session variables' do
+ end
+ end
+
+ describe 'GET status' do
+ it 'shows the list of projects to be imported' do
+ end
+ end
+
+ describe 'GET jobs' do
+ it 'returns a list of imported projects' do
+ end
+ end
+end