Commit 1c3121e5 authored by Thong Kuah's avatar Thong Kuah Committed by Jan Provaznik

Add facade which will always return nil in CE

This method will be overridden in EE
parent d12a06b7
......@@ -53,6 +53,11 @@ class ClusterablePresenter < Gitlab::View::Presenter::Delegated
raise NotImplementedError
end
# Will be overidden in EE
def environments_cluster_path(cluster)
nil
end
def empty_state_help_text
nil
end
......
......@@ -8,5 +8,18 @@ module EE
def metrics_cluster_path(cluster, params = {})
metrics_group_cluster_path(clusterable, cluster, params)
end
override :environments_cluster_path
def environments_cluster_path(cluster)
return super unless can_read_cluster_environments?
environments_group_cluster_path(clusterable, cluster)
end
private
def can_read_cluster_environments?
can?(current_user, :read_cluster_environments, clusterable)
end
end
end
......@@ -5,6 +5,8 @@ require 'spec_helper'
describe GroupClusterablePresenter do
include Gitlab::Routing.url_helpers
set(:user) { create(:user) }
let(:presenter) { described_class.new(group) }
let(:cluster) { create(:cluster, :provided_by_gcp, :group) }
let(:group) { cluster.group }
......@@ -14,4 +16,28 @@ describe GroupClusterablePresenter do
it { is_expected.to eq(metrics_group_cluster_path(group, cluster)) }
end
describe '#environments_cluster_path' do
subject { presenter.environments_cluster_path(cluster) }
before do
group.add_maintainer(user)
allow(presenter).to receive(:current_user).and_return(user)
stub_licensed_features(cluster_deployments: feature_available)
end
context 'cluster_deployments feature is available' do
let(:feature_available) { true }
it { is_expected.to eq(environments_group_cluster_path(group, cluster)) }
end
context 'cluster_deployments feature is not available' do
let(:feature_available) { false }
it { is_expected.to be_nil }
end
end
end
......@@ -78,4 +78,13 @@ describe ClusterablePresenter do
it_behaves_like 'appropriate member permissions'
end
end
describe '#environments_cluster_path' do
subject { described_class.new(clusterable).environments_cluster_path(cluster) }
let(:clusterable) { create(:group) }
let(:cluster) { create(:cluster_for_group, groups: [clusterable]) }
it { is_expected.to be_nil }
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