Commit 8bf64434 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '212704-fix-jira-graphql-key' into 'master'

Check if jira project key has been provided

See merge request gitlab-org/gitlab!28750
parents 6a1db320 36eca577
...@@ -22,8 +22,14 @@ module Projects ...@@ -22,8 +22,14 @@ module Projects
end end
def import def import
response = ::JiraImport::StartImportService.new(current_user, @project, jira_import_params[:jira_project_key]).execute jira_project_key = jira_import_params[:jira_project_key]
flash[:notice] = response.message if response.message.present?
if jira_project_key.present?
response = ::JiraImport::StartImportService.new(current_user, @project, jira_project_key).execute
flash[:notice] = response.message if response.message.present?
else
flash[:alert] = 'No jira project key has been provided.'
end
redirect_to project_import_jira_path(@project) redirect_to project_import_jira_path(@project)
end end
......
...@@ -93,18 +93,29 @@ describe Projects::Import::JiraController do ...@@ -93,18 +93,29 @@ describe Projects::Import::JiraController do
end end
context 'post import' do context 'post import' do
it 'creates import state' do context 'when jira project key is empty' do
expect(project.import_state).to be_nil it 'redirects back to show with an error' do
post :import, params: { namespace_id: project.namespace, project_id: project, jira_project_key: '' }
post :import, params: { namespace_id: project.namespace, project_id: project, jira_project_key: 'Test' } expect(response).to redirect_to(project_import_jira_path(project))
expect(flash[:alert]).to eq('No jira project key has been provided.')
end
end
project.reload context 'when everything is ok' do
it 'creates import state' do
expect(project.import_state).to be_nil
jira_project = project.import_data.data.dig('jira', 'projects').first post :import, params: { namespace_id: project.namespace, project_id: project, jira_project_key: 'Test' }
expect(project.import_type).to eq 'jira'
expect(project.import_state.status).to eq 'scheduled' project.reload
expect(jira_project['key']).to eq 'Test'
expect(response).to redirect_to(project_import_jira_path(project)) jira_project = project.import_data.data.dig('jira', 'projects').first
expect(project.import_type).to eq 'jira'
expect(project.import_state.status).to eq 'scheduled'
expect(jira_project['key']).to eq 'Test'
expect(response).to redirect_to(project_import_jira_path(project))
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment