Commit 582e4014 authored by Shinya Maeda's avatar Shinya Maeda

Restore unexpectedly removed code (Unrelated to this feature)

parent 232f4f1d
......@@ -5,6 +5,8 @@ module Clusters
include Gitlab::Kubernetes
include ReactiveCaching
prepend EE::KubernetesService
self.table_name = 'cluster_platforms_kubernetes'
self.reactive_cache_key = ->(kubernetes) { [kubernetes.class.model_name.singular, kubernetes.id] }
......
......@@ -145,6 +145,10 @@ class Environment < ActiveRecord::Base
project.deployment_platform.terminals(self) if has_terminals?
end
def rollout_status
project.deployment_platform.rollout_status(self) if has_terminals?
end
def has_metrics?
project.monitoring_service.present? && available? && last_deployment.present?
end
......
......@@ -20,6 +20,9 @@ class Project < ActiveRecord::Base
include GroupDescendant
include Gitlab::SQL::Pattern
# EE specific modules
prepend EE::Project
extend Gitlab::ConfigHelper
extend Gitlab::CurrentSettings
......@@ -100,6 +103,7 @@ class Project < ActiveRecord::Base
# Project services
has_one :campfire_service
has_one :drone_ci_service
has_one :gitlab_slack_application_service
has_one :emails_on_push_service
has_one :pipelines_email_service
has_one :irker_service
......@@ -390,10 +394,6 @@ class Project < ActiveRecord::Base
transition [:scheduled, :started] => :failed
end
event :import_retry do
transition failed: :started
end
state :scheduled
state :started
state :finished
......@@ -482,6 +482,14 @@ class Project < ActiveRecord::Base
.base_and_ancestors(upto: top)
end
def root_namespace
if namespace.has_parent?
namespace.root_ancestor
else
namespace
end
end
def lfs_enabled?
return namespace.lfs_enabled? if self[:lfs_enabled].nil?
......@@ -617,6 +625,8 @@ class Project < ActiveRecord::Base
else
super
end
rescue
super
end
def valid_import_url?
......@@ -1040,6 +1050,7 @@ class Project < ActiveRecord::Base
# Expires various caches before a project is renamed.
def expire_caches_before_rename(old_path)
# TODO: if we start using UUIDs for cache, we don't need to do this HACK anymore
repo = Repository.new(old_path, self)
wiki = Repository.new("#{old_path}.wiki", self)
......@@ -1619,10 +1630,6 @@ class Project < ActiveRecord::Base
feature_available?(:multiple_issue_boards, user)
end
def issue_board_milestone_available?(user = nil)
feature_available?(:issue_board_milestone, user)
end
def full_path_was
File.join(namespace.full_path, previous_changes['path'].first)
end
......
......@@ -23,7 +23,7 @@ class EnvironmentEntity < Grape::Entity
stop_project_environment_path(environment.project, environment)
end
expose :terminal_path, if: ->(*) { environment.deployment_service_ready? } do |environment|
expose :terminal_path, if: ->(*) { environment.has_terminals? } do |environment|
can?(request.current_user, :admin_environment, environment.project) &&
terminal_project_environment_path(environment.project, environment)
end
......
- if environment.deployment_service_ready? && can?(current_user, :admin_environment, @project)
- if environment.has_terminals? && can?(current_user, :admin_environment, @project)
= link_to terminal_project_environment_path(@project, environment), class: 'btn terminal-button' do
= icon('terminal')
......@@ -242,6 +242,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
context 'when kubernetes responds with valid pods' do
before do
stub_kubeclient_pods
stub_kubeclient_deployments
end
it { is_expected.to eq(pods: [kube_pod]) }
......@@ -250,6 +251,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
context 'when kubernetes responds with 500s' do
before do
stub_kubeclient_pods(status: 500)
stub_kubeclient_deployments(status: 500)
end
it { expect { subject }.to raise_error(KubeException) }
......@@ -258,9 +260,10 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
context 'when kubernetes responds with 404s' do
before do
stub_kubeclient_pods(status: 404)
stub_kubeclient_deployments(status: 404)
end
it { is_expected.to eq(pods: []) }
it { is_expected.to eq(pods: [], deployments: []) }
end
end
end
This diff is collapsed.
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