FIX ci connection database bug

This commit is contained in:
Jasder 2020-10-16 09:42:08 +08:00
parent a0c80d8d25
commit e430645304
3 changed files with 6 additions and 2 deletions

View File

@ -2,7 +2,7 @@ class Ci::BaseController < ApplicationController
include Ci::DbConnectable
before_action :require_login
before_action :connect_to_ci_database, if: -> { current_user && !current_user.is_a?(AnonymousUser) && current_user.devops_unverified? }
before_action :connect_to_ci_database, if: -> { current_user && !current_user.is_a?(AnonymousUser) && current_user.devops_certification? }
def load_repo
namespace = params[:owner]

View File

@ -58,7 +58,7 @@ module Ci::CloudAccountManageable
if current_user.devops_step == User::DEVOPS_UNINIT || cloud_account.blank?
return render_error('你未绑定CI服务器')
elsif current_user.devops_step != User::DEVOPS_UNINIT || current_user.ci_certification?
elsif current_user.ci_certification?
cloud_account.destroy!
# TOTO drop drone database
@connection.execute("DROP DATABASE IF EXISTS #{current_user.login}_drone")

View File

@ -12,6 +12,10 @@ module Droneable
self.devops_step === User::DEVOPS_UNVERIFIED
end
def devops_certification?
self.devops_step === User::DEVOPS_CERTIFICATION
end
def set_drone_step!(step)
self.update_column(:devops_step, step)
end