gitlab-org--gitlab-foss/spec/lib/gitlab/gitlab_import/importer_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.4 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-07-11 21:32:42 +00:00
require 'spec_helper'
RSpec.describe Gitlab::GitlabImport::Importer do
2016-07-11 22:03:06 +00:00
include ImportSpecHelper
2016-07-11 21:32:42 +00:00
describe '#execute' do
2016-07-11 22:03:06 +00:00
before do
stub_omniauth_provider('gitlab')
2016-07-11 21:32:42 +00:00
stub_request('issues', [
{
'id' => 2579857,
'iid' => 3,
'title' => 'Issue',
'description' => 'Lorem ipsum',
'state' => 'opened',
'confidential' => true,
2016-07-11 21:32:42 +00:00
'author' => {
'id' => 283999,
'name' => 'John Doe'
}
}
].to_json)
stub_request('issues/3/notes', [].to_json)
2016-07-11 22:03:06 +00:00
end
2016-07-11 21:32:42 +00:00
2016-07-11 22:03:06 +00:00
it 'persists issues' do
project = create(:project, import_source: 'asd/vim')
2016-07-11 21:32:42 +00:00
project.build_import_data(credentials: { password: 'password' })
subject = described_class.new(project)
subject.execute
expected_attributes = {
iid: 3,
title: 'Issue',
description: "*Created by: John Doe*\n\nLorem ipsum",
state: 'opened',
confidential: true,
2016-07-11 21:32:42 +00:00
author_id: project.creator_id
}
expect(project.issues.first).to have_attributes(expected_attributes)
end
def stub_request(path, body)
2018-05-15 13:39:33 +00:00
url = "https://gitlab.com/api/v4/projects/asd%2Fvim/#{path}?page=1&per_page=100"
2016-07-11 21:32:42 +00:00
2017-06-21 13:48:12 +00:00
WebMock.stub_request(:get, url)
.to_return(
2016-07-11 21:32:42 +00:00
headers: { 'Content-Type' => 'application/json' },
body: body
)
end
end
end