diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-07-12 00:32:42 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-07-13 17:35:38 +0300 |
commit | d9564ed73369e35b5623ead35de5e7a8cda3f7ec (patch) | |
tree | 6d1c25869f83c350550c284872e2cf85916f024f /spec/lib/gitlab/gitlab_import | |
parent | a14ee9bef9050e9d4c4de63eec80e9ff33c7e039 (diff) |
Add spec for GitLab.com importer
Diffstat (limited to 'spec/lib/gitlab/gitlab_import')
-rw-r--r-- | spec/lib/gitlab/gitlab_import/importer_spec.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/lib/gitlab/gitlab_import/importer_spec.rb b/spec/lib/gitlab/gitlab_import/importer_spec.rb new file mode 100644 index 00000000000..5fa81b9716a --- /dev/null +++ b/spec/lib/gitlab/gitlab_import/importer_spec.rb @@ -0,0 +1,48 @@ +require 'spec_helper' + +describe Gitlab::GitlabImport::Importer, lib: true do + describe '#execute' do + it 'persists issues' do + stub_request('issues', [ + { + 'id' => 2579857, + 'iid' => 3, + 'title' => 'Issue', + 'description' => 'Lorem ipsum', + 'state' => 'opened', + 'author' => { + 'id' => 283999, + 'name' => 'John Doe' + } + } + ]) + stub_request('issues/2579857/notes', []) + + project = create(:empty_project, import_source: 'asd/vim') + 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', + author_id: project.creator_id + } + + expect(project.issues.first).to have_attributes(expected_attributes) + end + + def stub_request(path, body) + url = "https://gitlab.com/api/v3/projects/asd%2Fvim/#{path}?page=1&per_page=100" + + WebMock.stub_request(:get, url). + to_return( + headers: { 'Content-Type' => 'application/json' }, + body: body + ) + end + end +end |