Commit fec402ae authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch '34758-unique-environment-scope' into 'master'

Sync `groups` and `group` to fix EE validation

See merge request gitlab-org/gitlab-ce!22788
parents 485a0bf7 1b47b214
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
module Clusters module Clusters
class Cluster < ActiveRecord::Base class Cluster < ActiveRecord::Base
include Presentable include Presentable
include Gitlab::Utils::StrongMemoize
self.table_name = 'clusters' self.table_name = 'clusters'
...@@ -24,9 +25,6 @@ module Clusters ...@@ -24,9 +25,6 @@ module Clusters
has_many :cluster_groups, class_name: 'Clusters::Group' has_many :cluster_groups, class_name: 'Clusters::Group'
has_many :groups, through: :cluster_groups, class_name: '::Group' has_many :groups, through: :cluster_groups, class_name: '::Group'
has_one :cluster_group, -> { order(id: :desc) }, class_name: 'Clusters::Group'
has_one :group, through: :cluster_group, class_name: '::Group'
# we force autosave to happen when we save `Cluster` model # we force autosave to happen when we save `Cluster` model
has_one :provider_gcp, class_name: 'Clusters::Providers::Gcp', autosave: true has_one :provider_gcp, class_name: 'Clusters::Providers::Gcp', autosave: true
...@@ -119,12 +117,19 @@ module Clusters ...@@ -119,12 +117,19 @@ module Clusters
end end
def first_project def first_project
return @first_project if defined?(@first_project) strong_memoize(:first_project) do
projects.first
@first_project = projects.first end
end end
alias_method :project, :first_project alias_method :project, :first_project
def first_group
strong_memoize(:first_group) do
groups.first
end
end
alias_method :group, :first_group
def kubeclient def kubeclient
platform_kubernetes.kubeclient if kubernetes? platform_kubernetes.kubeclient if kubernetes?
end end
......
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