2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Gitlab::BitbucketImport::ProjectCreator do
|
2015-09-25 12:07:36 +05:30
|
|
|
let(:user) { create(:user) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
let(:repo) do
|
2017-08-17 22:00:37 +05:30
|
|
|
double(name: 'Vim',
|
|
|
|
slug: 'vim',
|
|
|
|
description: 'Test repo',
|
|
|
|
is_private: true,
|
|
|
|
owner: "asd",
|
|
|
|
full_name: 'Vim repo',
|
|
|
|
visibility_level: Gitlab::VisibilityLevel::PRIVATE,
|
2018-12-13 13:39:08 +05:30
|
|
|
clone_url: 'http://bitbucket.org/asd/vim.git',
|
2017-08-17 22:00:37 +05:30
|
|
|
has_wiki?: false)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
let(:namespace) { create(:group) }
|
2015-09-25 12:07:36 +05:30
|
|
|
let(:token) { "asdasd12345" }
|
|
|
|
let(:secret) { "sekrettt" }
|
|
|
|
let(:access_params) { { bitbucket_access_token: token, bitbucket_access_token_secret: secret } }
|
2015-04-26 12:48:37 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
namespace.add_owner(user)
|
|
|
|
end
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
it 'creates project' do
|
2018-11-08 19:23:39 +05:30
|
|
|
expect_next_instance_of(Project) do |project|
|
|
|
|
expect(project).to receive(:add_import_job)
|
|
|
|
end
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
project_creator = described_class.new(repo, 'vim', namespace, user, access_params)
|
2015-04-26 12:48:37 +05:30
|
|
|
project = project_creator.execute
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(project.import_url).to eq("http://bitbucket.org/asd/vim.git")
|
2015-04-26 12:48:37 +05:30
|
|
|
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
|
|
|
|
end
|
|
|
|
end
|