Commit 36eca577 authored by Jarka Košanová's avatar Jarka Košanová

Check if jira project key has been provided

parent 345156aa
...@@ -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]
if jira_project_key.present?
response = ::JiraImport::StartImportService.new(current_user, @project, jira_project_key).execute
flash[:notice] = response.message if response.message.present? 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,6 +93,16 @@ describe Projects::Import::JiraController do ...@@ -93,6 +93,16 @@ describe Projects::Import::JiraController do
end end
context 'post import' do 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 it 'creates import state' do
expect(project.import_state).to be_nil expect(project.import_state).to be_nil
...@@ -108,6 +118,7 @@ describe Projects::Import::JiraController do ...@@ -108,6 +118,7 @@ describe Projects::Import::JiraController do
end end
end end
end end
end
context 'when import state is scheduled' do context 'when import state is scheduled' do
let_it_be(:import_state) { create(:import_state, project: project, status: :scheduled) } 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