2018-10-22 23:51:29 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe GroupClusterablePresenter do
|
2018-10-22 23:51:29 -04:00
|
|
|
include Gitlab::Routing.url_helpers
|
|
|
|
|
|
|
|
let(:presenter) { described_class.new(group) }
|
|
|
|
let(:cluster) { create(:cluster, :provided_by_gcp, :group) }
|
|
|
|
let(:group) { cluster.group }
|
|
|
|
|
|
|
|
describe '#can_create_cluster?' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
subject { presenter.can_create_cluster? }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(presenter).to receive(:current_user).and_return(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user can create' do
|
|
|
|
before do
|
|
|
|
group.add_maintainer(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to be_truthy }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user cannot create' do
|
|
|
|
it { is_expected.to be_falsey }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#index_path' do
|
|
|
|
subject { presenter.index_path }
|
|
|
|
|
|
|
|
it { is_expected.to eq(group_clusters_path(group)) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#new_path' do
|
|
|
|
subject { presenter.new_path }
|
|
|
|
|
|
|
|
it { is_expected.to eq(new_group_cluster_path(group)) }
|
|
|
|
end
|
|
|
|
|
2019-11-08 01:06:24 -05:00
|
|
|
describe '#authorize_aws_role_path' do
|
|
|
|
subject { presenter.authorize_aws_role_path }
|
|
|
|
|
|
|
|
it { is_expected.to eq(authorize_aws_role_group_clusters_path(group)) }
|
|
|
|
end
|
|
|
|
|
2018-10-22 23:51:29 -04:00
|
|
|
describe '#create_user_clusters_path' do
|
|
|
|
subject { presenter.create_user_clusters_path }
|
|
|
|
|
|
|
|
it { is_expected.to eq(create_user_group_clusters_path(group)) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#create_gcp_clusters_path' do
|
|
|
|
subject { presenter.create_gcp_clusters_path }
|
|
|
|
|
|
|
|
it { is_expected.to eq(create_gcp_group_clusters_path(group)) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#cluster_status_cluster_path' do
|
|
|
|
subject { presenter.cluster_status_cluster_path(cluster) }
|
|
|
|
|
|
|
|
it { is_expected.to eq(cluster_status_group_cluster_path(group, cluster)) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#install_applications_cluster_path' do
|
|
|
|
let(:application) { :helm }
|
|
|
|
|
|
|
|
subject { presenter.install_applications_cluster_path(cluster, application) }
|
|
|
|
|
|
|
|
it { is_expected.to eq(install_applications_group_cluster_path(group, cluster, application)) }
|
|
|
|
end
|
|
|
|
|
2019-03-04 05:08:53 -05:00
|
|
|
describe '#update_applications_cluster_path' do
|
|
|
|
let(:application) { :helm }
|
|
|
|
|
|
|
|
subject { presenter.update_applications_cluster_path(cluster, application) }
|
|
|
|
|
|
|
|
it { is_expected.to eq(update_applications_group_cluster_path(group, cluster, application)) }
|
|
|
|
end
|
|
|
|
|
2019-11-26 04:08:36 -05:00
|
|
|
describe '#clear_cluster_cache_path' do
|
|
|
|
subject { presenter.clear_cluster_cache_path(cluster) }
|
|
|
|
|
|
|
|
it { is_expected.to eq(clear_cache_group_cluster_path(group, cluster)) }
|
|
|
|
end
|
|
|
|
|
2018-10-22 23:51:29 -04:00
|
|
|
describe '#cluster_path' do
|
|
|
|
subject { presenter.cluster_path(cluster) }
|
|
|
|
|
|
|
|
it { is_expected.to eq(group_cluster_path(group, cluster)) }
|
|
|
|
end
|
2020-07-13 11:09:08 -04:00
|
|
|
|
|
|
|
describe '#metrics_dashboard_path' do
|
|
|
|
subject { presenter.metrics_dashboard_path(cluster) }
|
|
|
|
|
|
|
|
it { is_expected.to eq(metrics_dashboard_group_cluster_path(group, cluster)) }
|
|
|
|
end
|
2018-10-22 23:51:29 -04:00
|
|
|
end
|