diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-05-30 12:02:45 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-05-30 12:02:45 +0300 |
commit | c075a047cd89ad53839b877a6dc8f4dbf970c5fb (patch) | |
tree | 331146ca6ef969b5a9736d4dff4af03d42024336 /app/controllers/projects/clusters | |
parent | 698cd3977b7d6089a8a98024f9e68beddbc07b86 (diff) |
Refactor cluster app creation code in controller
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/controllers/projects/clusters')
-rw-r--r-- | app/controllers/projects/clusters/applications_controller.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/app/controllers/projects/clusters/applications_controller.rb b/app/controllers/projects/clusters/applications_controller.rb index 6de7a332164..ce04c186dc0 100644 --- a/app/controllers/projects/clusters/applications_controller.rb +++ b/app/controllers/projects/clusters/applications_controller.rb @@ -5,17 +5,18 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll before_action :authorize_create_cluster!, only: [:create] def create - application = @application_class.find_or_create_by!(cluster: @cluster) + application = @application_class.find_or_initialize_by(cluster: @cluster) - if application.respond_to?(:hostname) - application.update(hostname: params[:hostname]) + if has_attribute?(:hostname) + application.hostname = params[:hostname] end if application.respond_to?(:oauth_application) application.oauth_application = create_oauth_application(application) - application.save end + application.save! + Clusters::Applications::ScheduleInstallationService.new(project, current_user).execute(application) head :no_content |