summaryrefslogtreecommitdiff
path: root/spec/controllers/groups
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2018-11-05 19:05:10 +0100
committerThong Kuah <tkuah@gitlab.com>2018-11-08 23:26:04 +1300
commit675bfd50a9483bfefea6a374c9d9024331a5c970 (patch)
tree27a0cae052b2f3de1dc461cf1f04d5ac717ac87b /spec/controllers/groups
parenta90320f792f9faefa3d5198e17b94f3acec7c6a5 (diff)
downloadgitlab-ce-675bfd50a9483bfefea6a374c9d9024331a5c970.tar.gz
Adds feature flag for Group Clusters
As the frontend is still in progress and other related backend is still in prgress we need a feature flag to turn off Group Clusters.
Diffstat (limited to 'spec/controllers/groups')
-rw-r--r--spec/controllers/groups/clusters_controller_spec.rb74
1 files changed, 46 insertions, 28 deletions
diff --git a/spec/controllers/groups/clusters_controller_spec.rb b/spec/controllers/groups/clusters_controller_spec.rb
index 05dc30c8fdf..5550da16037 100644
--- a/spec/controllers/groups/clusters_controller_spec.rb
+++ b/spec/controllers/groups/clusters_controller_spec.rb
@@ -20,45 +20,63 @@ describe Groups::ClustersController do
get :index, params.reverse_merge(group_id: group)
end
- describe 'functionality' do
- context 'when group has one or more clusters' do
- let(:group) { create(:group) }
- let!(:enabled_cluster) { create(:cluster, :provided_by_gcp, cluster_type: :group_type, groups: [group]) }
- let!(:disabled_cluster) { create(:cluster, :disabled, :provided_by_gcp, :production_environment, cluster_type: :group_type, groups: [group]) }
- it 'lists available clusters' do
- go
+ context 'when feature flag is not enabled' do
+ before do
+ stub_feature_flags(group_clusters: false)
+ end
- expect(response).to have_gitlab_http_status(:ok)
- expect(response).to render_template(:index)
- expect(assigns(:clusters)).to match_array([enabled_cluster, disabled_cluster])
- end
+ it 'renders 404' do
+ go
- context 'when page is specified' do
- let(:last_page) { group.clusters.page.total_pages }
+ expect(response).to have_gitlab_http_status(404)
+ end
+ end
- before do
- allow(Clusters::Cluster).to receive(:paginates_per).and_return(1)
- create_list(:cluster, 2, :provided_by_gcp, :production_environment, cluster_type: :group_type, groups: [group])
- end
+ context 'when feature flag is enabled' do
+ before do
+ stub_feature_flags(group_clusters: true)
+ end
- it 'redirects to the page' do
- go(page: last_page)
+ describe 'functionality' do
+ context 'when group has one or more clusters' do
+ let(:group) { create(:group) }
+ let!(:enabled_cluster) { create(:cluster, :provided_by_gcp, cluster_type: :group_type, groups: [group]) }
+ let!(:disabled_cluster) { create(:cluster, :disabled, :provided_by_gcp, :production_environment, cluster_type: :group_type, groups: [group]) }
+ it 'lists available clusters' do
+ go
expect(response).to have_gitlab_http_status(:ok)
- expect(assigns(:clusters).current_page).to eq(last_page)
+ expect(response).to render_template(:index)
+ expect(assigns(:clusters)).to match_array([enabled_cluster, disabled_cluster])
+ end
+
+ context 'when page is specified' do
+ let(:last_page) { group.clusters.page.total_pages }
+
+ before do
+ allow(Clusters::Cluster).to receive(:paginates_per).and_return(1)
+ create_list(:cluster, 2, :provided_by_gcp, :production_environment, cluster_type: :group_type, groups: [group])
+ end
+
+ it 'redirects to the page' do
+ go(page: last_page)
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(assigns(:clusters).current_page).to eq(last_page)
+ end
end
end
- end
- context 'when group does not have a cluster' do
- let(:group) { create(:group) }
+ context 'when group does not have a cluster' do
+ let(:group) { create(:group) }
- it 'returns an empty state page' do
- go
+ it 'returns an empty state page' do
+ go
- expect(response).to have_gitlab_http_status(:ok)
- expect(response).to render_template(:index, partial: :empty_state)
- expect(assigns(:clusters)).to eq([])
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(response).to render_template(:index, partial: :empty_state)
+ expect(assigns(:clusters)).to eq([])
+ end
end
end
end