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
end
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]
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)
end
......
......@@ -93,6 +93,16 @@ describe Projects::Import::JiraController do
end
context 'post import' do
context 'when jira project key is empty' do
it 'redirects back to show with an error' do
post :import, params: { namespace_id: project.namespace, project_id: project, jira_project_key: '' }
expect(response).to redirect_to(project_import_jira_path(project))
expect(flash[:alert]).to eq('No jira project key has been provided.')
end
end
context 'when everything is ok' do
it 'creates import state' do
expect(project.import_state).to be_nil
......@@ -108,6 +118,7 @@ describe Projects::Import::JiraController do
end
end
end
end
context 'when import state is scheduled' do
let_it_be(:import_state) { create(:import_state, project: project, status: :scheduled) }
......
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