debian-mirror-gitlab/spec/lib/gitlab/gitlab_import/importer_spec.rb

58 lines
1.4 KiB
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
2016-08-24 12:49:21 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::GitlabImport::Importer do
2016-08-24 12:49:21 +05:30
include ImportSpecHelper
describe '#execute' do
before do
stub_omniauth_provider('gitlab')
stub_request('issues', [
{
'id' => 2579857,
'iid' => 3,
'title' => 'Issue',
'description' => 'Lorem ipsum',
'state' => 'opened',
2016-09-29 09:46:39 +05:30
'confidential' => true,
2016-08-24 12:49:21 +05:30
'author' => {
'id' => 283999,
'name' => 'John Doe'
}
}
])
2018-11-08 19:23:39 +05:30
stub_request('issues/3/notes', [])
2016-08-24 12:49:21 +05:30
end
it 'persists issues' do
2017-09-10 17:25:29 +05:30
project = create(:project, import_source: 'asd/vim')
2016-08-24 12:49:21 +05:30
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',
2016-09-29 09:46:39 +05:30
confidential: true,
2016-08-24 12:49:21 +05:30
author_id: project.creator_id
}
expect(project.issues.first).to have_attributes(expected_attributes)
end
def stub_request(path, body)
2018-11-08 19:23:39 +05:30
url = "https://gitlab.com/api/v4/projects/asd%2Fvim/#{path}?page=1&per_page=100"
2016-08-24 12:49:21 +05:30
2017-09-10 17:25:29 +05:30
WebMock.stub_request(:get, url)
.to_return(
2016-08-24 12:49:21 +05:30
headers: { 'Content-Type' => 'application/json' },
body: body
)
end
end
end