diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 21:38:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 21:38:24 +0300 |
commit | 983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch) | |
tree | b153cd387c14ba23bd5a07514c7c01fddf6a78a0 /spec/services/jira_import | |
parent | a2bddee2cdb38673df0e004d5b32d9f77797de64 (diff) |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'spec/services/jira_import')
-rw-r--r-- | spec/services/jira_import/start_import_service_spec.rb | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/spec/services/jira_import/start_import_service_spec.rb b/spec/services/jira_import/start_import_service_spec.rb index ae0c4f63fee..90f38945a9f 100644 --- a/spec/services/jira_import/start_import_service_spec.rb +++ b/spec/services/jira_import/start_import_service_spec.rb @@ -5,8 +5,9 @@ require 'spec_helper' describe JiraImport::StartImportService do let_it_be(:user) { create(:user) } let_it_be(:project, reload: true) { create(:project) } + let(:key) { 'KEY' } - subject { described_class.new(user, project, '').execute } + subject { described_class.new(user, project, key).execute } context 'when feature flag disabled' do before do @@ -23,6 +24,8 @@ describe JiraImport::StartImportService do context 'when user does not have permissions to run the import' do before do + create(:jira_service, project: project, active: true) + project.add_developer(user) end @@ -38,19 +41,21 @@ describe JiraImport::StartImportService do it_behaves_like 'responds with error', 'Jira integration not configured.' end - context 'when issues feature are disabled' do - let_it_be(:project, reload: true) { create(:project, :issues_disabled) } - - it_behaves_like 'responds with error', 'Cannot import because issues are not available in this project.' - end - context 'when Jira service exists' do let!(:jira_service) { create(:jira_service, project: project, active: true) } context 'when Jira project key is not provided' do + let(:key) { '' } + it_behaves_like 'responds with error', 'Unable to find Jira project to import data from.' end + context 'when issues feature are disabled' do + let_it_be(:project, reload: true) { create(:project, :issues_disabled) } + + it_behaves_like 'responds with error', 'Cannot import because issues are not available in this project.' + end + context 'when correct data provided' do let(:fake_key) { 'some-key' } @@ -62,15 +67,17 @@ describe JiraImport::StartImportService do it_behaves_like 'responds with error', 'Jira import is already running.' end - it 'returns success response' do - expect(subject).to be_a(ServiceResponse) - expect(subject).to be_success - end + context 'when everything is ok' do + it 'returns success response' do + expect(subject).to be_a(ServiceResponse) + expect(subject).to be_success + end - it 'schedules jira import' do - subject + it 'schedules jira import' do + subject - expect(project.latest_jira_import).to be_scheduled + expect(project.latest_jira_import).to be_scheduled + end end it 'creates jira import data' do |