summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessio Caiazza <acaiazza@gitlab.com>2017-11-06 18:21:10 +0100
committerAlessio Caiazza <acaiazza@gitlab.com>2017-11-06 18:21:10 +0100
commitf676f388153fc9b5da0a76b2d5c2af9d8ffe832c (patch)
treef7e7b576cdd57bae600e2df276401f8b158c5b69
parent2b4fccb7205101480bae2668e681cb3b58fface5 (diff)
downloadgitlab-ce-38464-k8s-apps.tar.gz
Add more tests to Projects::Clusters::ApplicationsController38464-k8s-apps
-rw-r--r--app/controllers/projects/clusters/applications_controller.rb14
-rw-r--r--spec/controllers/projects/clusters/applications_controller_spec.rb13
2 files changed, 19 insertions, 8 deletions
diff --git a/app/controllers/projects/clusters/applications_controller.rb b/app/controllers/projects/clusters/applications_controller.rb
index 4b9d54a8537..90c7fa62216 100644
--- a/app/controllers/projects/clusters/applications_controller.rb
+++ b/app/controllers/projects/clusters/applications_controller.rb
@@ -5,14 +5,12 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll
before_action :authorize_create_cluster!, only: [:create]
def create
- scheduled = Clusters::Applications::ScheduleInstallationService.new(project, current_user,
- application_class: @application_class,
- cluster: @cluster).execute
- if scheduled
- head :no_content
- else
- head :bad_request
- end
+ Clusters::Applications::ScheduleInstallationService.new(project, current_user,
+ application_class: @application_class,
+ cluster: @cluster).execute
+ head :no_content
+ rescue StandardError
+ head :bad_request
end
private
diff --git a/spec/controllers/projects/clusters/applications_controller_spec.rb b/spec/controllers/projects/clusters/applications_controller_spec.rb
index b8464b713c4..3213a797756 100644
--- a/spec/controllers/projects/clusters/applications_controller_spec.rb
+++ b/spec/controllers/projects/clusters/applications_controller_spec.rb
@@ -49,6 +49,19 @@ describe Projects::Clusters::ApplicationsController do
expect(response).to have_http_status(:not_found)
end
end
+
+ context 'when application is already installing' do
+ before do
+ other = current_application.new(cluster: cluster)
+ other.make_installing!
+ end
+
+ it 'returns 400' do
+ go
+
+ expect(response).to have_http_status(:bad_request)
+ end
+ end
end
describe 'security' do