Commit fc8214ea authored by Robert Speicher's avatar Robert Speicher Committed by Yorick Peterse

Merge branch 'fix/import-url-issues' into 'master'

Fix importer bug when throwing exceptions

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/15681

See merge request !3941
parent 1d72f956
...@@ -12,7 +12,7 @@ module Gitlab ...@@ -12,7 +12,7 @@ module Gitlab
token_secret = import_data_credentials[:bb_session][:bitbucket_access_token_secret] token_secret = import_data_credentials[:bb_session][:bitbucket_access_token_secret]
new(token, token_secret) new(token, token_secret)
else else
raise Projects::ImportService::Error, "Unable to find project import data credentials for project ID: #{@project.id}" raise Projects::ImportService::Error, "Unable to find project import data credentials for project ID: #{project.id}"
end end
end end
......
...@@ -34,18 +34,32 @@ describe Gitlab::BitbucketImport::Client, lib: true do ...@@ -34,18 +34,32 @@ describe Gitlab::BitbucketImport::Client, lib: true do
it 'retrieves issues over a number of pages' do it 'retrieves issues over a number of pages' do
stub_request(:get, stub_request(:get,
"https://bitbucket.org/api/1.0/repositories/#{project_id}/issues?limit=50&sort=utc_created_on&start=0"). "https://bitbucket.org/api/1.0/repositories/#{project_id}/issues?limit=50&sort=utc_created_on&start=0").
to_return(status: 200, to_return(status: 200,
body: first_sample_data.to_json, body: first_sample_data.to_json,
headers: {}) headers: {})
stub_request(:get, stub_request(:get,
"https://bitbucket.org/api/1.0/repositories/#{project_id}/issues?limit=50&sort=utc_created_on&start=50"). "https://bitbucket.org/api/1.0/repositories/#{project_id}/issues?limit=50&sort=utc_created_on&start=50").
to_return(status: 200, to_return(status: 200,
body: second_sample_data.to_json, body: second_sample_data.to_json,
headers: {}) headers: {})
issues = client.issues(project_id) issues = client.issues(project_id)
expect(issues.count).to eq(95) expect(issues.count).to eq(95)
end end
end end
context 'project import' do
it 'calls .from_project with no errors' do
project = create(:empty_project)
project.create_or_update_import_data(credentials:
{ user: "git",
password: nil,
bb_session: { bitbucket_access_token: "test",
bitbucket_access_token_secret: "test" } })
project.import_url = "ssh://git@bitbucket.org/test/test.git"
expect { described_class.from_project(project) }.to_not raise_error
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment