2018-10-30 06:33:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe ProjectClusterablePresenter do
|
2018-10-30 06:33:43 -04:00
|
|
|
include Gitlab::Routing.url_helpers
|
|
|
|
|
|
|
|
let(:presenter) { described_class.new(project) }
|
|
|
|
let(:project) { create(:project) }
|
2018-11-01 16:48:38 -04:00
|
|
|
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
|
2018-10-30 06:33:43 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
project.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(project_clusters_path(project)) }
|
|
|
|
end
|
|
|
|
|
2022-03-16 14:08:16 -04:00
|
|
|
describe '#connect_path' do
|
|
|
|
subject { presenter.connect_path }
|
|
|
|
|
|
|
|
it { is_expected.to eq(connect_project_clusters_path(project)) }
|
|
|
|
end
|
|
|
|
|
2022-03-28 05:07:06 -04:00
|
|
|
describe '#new_cluster_docs_path' do
|
|
|
|
subject { presenter.new_cluster_docs_path }
|
|
|
|
|
|
|
|
it { is_expected.to eq(new_cluster_docs_project_clusters_path(project)) }
|
|
|
|
end
|
|
|
|
|
2018-11-01 16:48:38 -04:00
|
|
|
describe '#create_user_clusters_path' do
|
|
|
|
subject { presenter.create_user_clusters_path }
|
|
|
|
|
|
|
|
it { is_expected.to eq(create_user_project_clusters_path(project)) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#cluster_status_cluster_path' do
|
|
|
|
subject { presenter.cluster_status_cluster_path(cluster) }
|
|
|
|
|
|
|
|
it { is_expected.to eq(cluster_status_project_cluster_path(project, cluster)) }
|
|
|
|
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_project_cluster_path(project, cluster)) }
|
|
|
|
end
|
|
|
|
|
2018-11-01 16:48:38 -04:00
|
|
|
describe '#cluster_path' do
|
|
|
|
subject { presenter.cluster_path(cluster) }
|
|
|
|
|
|
|
|
it { is_expected.to eq(project_cluster_path(project, 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_project_cluster_path(project, cluster)) }
|
|
|
|
end
|
2021-09-28 05:11:19 -04:00
|
|
|
|
|
|
|
describe '#learn_more_link' do
|
|
|
|
subject { presenter.learn_more_link }
|
|
|
|
|
|
|
|
it { is_expected.to include('user/project/clusters/index') }
|
|
|
|
end
|
2018-10-30 06:33:43 -04:00
|
|
|
end
|