diff options
Diffstat (limited to 'spec/lib/gitlab/jira_import')
-rw-r--r-- | spec/lib/gitlab/jira_import/labels_importer_spec.rb | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/spec/lib/gitlab/jira_import/labels_importer_spec.rb b/spec/lib/gitlab/jira_import/labels_importer_spec.rb index 2d0e2bc6b53..3eb4666a74f 100644 --- a/spec/lib/gitlab/jira_import/labels_importer_spec.rb +++ b/spec/lib/gitlab/jira_import/labels_importer_spec.rb @@ -5,7 +5,6 @@ require 'spec_helper' describe Gitlab::JiraImport::LabelsImporter do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project) } - let_it_be(:jira_import) { create(:jira_import_state, project: project) } let_it_be(:jira_service) { create(:jira_service, project: project) } subject { described_class.new(project).execute } @@ -15,29 +14,24 @@ describe Gitlab::JiraImport::LabelsImporter do end describe '#execute', :clean_gitlab_redis_cache do - context 'when label creation failes' do - before do - allow_next_instance_of(Labels::CreateService) do |instance| - allow(instance).to receive(:execute).and_return(nil) - end - end + context 'when label is missing from jira import' do + let_it_be(:no_label_jira_import) { create(:jira_import_state, label: nil, project: project) } it 'raises error' do - expect { subject }.to raise_error(Projects::ImportService::Error, 'Failed to create import label for jira import.') + expect { subject }.to raise_error(Projects::ImportService::Error, 'Failed to find import label for jira import.') end end - context 'when label is created successfully' do - it 'creates import label' do - expect { subject }.to change { Label.count }.by(1) - end + context 'when label exists' do + let_it_be(:label) { create(:label) } + let_it_be(:jira_import_with_label) { create(:jira_import_state, label: label, project: project) } it 'caches import label' do expect(Gitlab::Cache::Import::Caching.read(Gitlab::JiraImport.import_label_cache_key(project.id))).to be nil subject - expect(Gitlab::JiraImport.get_import_label_id(project.id).to_i).to be > 0 + expect(Gitlab::JiraImport.get_import_label_id(project.id).to_i).to eq(label.id) end end end |