diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-07 00:07:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-07 00:07:51 +0000 |
commit | 4e375367b78bb44bd00957522cd9fc3e6d403fef (patch) | |
tree | 059b1ce541e4128bf03683407d7b5bbbc2094ed5 /spec/lib/gitlab/fogbugz_import | |
parent | 99ddca0d88f1e4e49d61b1aa9d41b5785528d1dc (diff) | |
download | gitlab-ce-4e375367b78bb44bd00957522cd9fc3e6d403fef.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/fogbugz_import')
-rw-r--r-- | spec/lib/gitlab/fogbugz_import/client_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/fogbugz_import/importer_spec.rb | 73 |
2 files changed, 76 insertions, 1 deletions
diff --git a/spec/lib/gitlab/fogbugz_import/client_spec.rb b/spec/lib/gitlab/fogbugz_import/client_spec.rb index 676511211c8..ca6f374476c 100644 --- a/spec/lib/gitlab/fogbugz_import/client_spec.rb +++ b/spec/lib/gitlab/fogbugz_import/client_spec.rb @@ -20,6 +20,8 @@ describe Gitlab::FogbugzImport::Client do end def stub_api(users) - allow_any_instance_of(::Fogbugz::Interface).to receive(:command).with(:listPeople).and_return(users) + allow_next_instance_of(::Fogbugz::Interface) do |instance| + allow(instance).to receive(:command).with(:listPeople).and_return(users) + end end end diff --git a/spec/lib/gitlab/fogbugz_import/importer_spec.rb b/spec/lib/gitlab/fogbugz_import/importer_spec.rb new file mode 100644 index 00000000000..9e67047eeda --- /dev/null +++ b/spec/lib/gitlab/fogbugz_import/importer_spec.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::FogbugzImport::Importer do + let(:project) { create(:project_empty_repo) } + let(:importer) { described_class.new(project) } + let(:repo) do + instance_double(Gitlab::FogbugzImport::Repository, + safe_name: 'vim', + path: 'vim', + raw_data: '') + end + let(:import_data) { { 'repo' => repo } } + let(:credentials) do + { + 'fb_session' => { + 'uri' => 'https://testing.fogbugz.com', + 'token' => 'token' + } + } + end + + let(:closed_bug) do + { + fOpen: 'false', + sTitle: 'Closed bug', + sLatestTextSummary: "", + dtOpened: Time.now.to_s, + dtLastUpdated: Time.now.to_s, + events: { event: [] } + }.with_indifferent_access + end + + let(:opened_bug) do + { + fOpen: 'true', + sTitle: 'Opened bug', + sLatestTextSummary: "", + dtOpened: Time.now.to_s, + dtLastUpdated: Time.now.to_s, + events: { event: [] } + }.with_indifferent_access + end + + let(:fogbugz_bugs) { [opened_bug, closed_bug] } + + before do + project.create_import_data(data: import_data, credentials: credentials) + allow_any_instance_of(::Fogbugz::Interface).to receive(:command).with(:listCategories).and_return([]) + allow_any_instance_of(Gitlab::FogbugzImport::Client).to receive(:cases).and_return(fogbugz_bugs) + end + + it 'imports bugs' do + expect { importer.execute }.to change { Issue.count }.by(2) + end + + it 'imports opened bugs' do + importer.execute + + issue = Issue.where(project_id: project.id).find_by_title(opened_bug[:sTitle]) + + expect(issue.state_id).to eq(Issue.available_states[:opened]) + end + + it 'imports closed bugs' do + importer.execute + + issue = Issue.where(project_id: project.id).find_by_title(closed_bug[:sTitle]) + + expect(issue.state_id).to eq(Issue.available_states[:closed]) + end +end |