diff options
author | Enrique Alcántara <ealcantara@gitlab.com> | 2019-09-09 23:27:51 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-09-09 23:27:51 +0300 |
commit | 90e3a4919fd977c1615a5270fd49146140159f6c (patch) | |
tree | a6a304f25a361037a94d4dcb3468344feeda5d78 /spec/controllers | |
parent | 56342d8895da85f71900ec7be171d7a2daea5ee0 (diff) |
Create new feature flagged UI for cloud providers
- Create HAML UI select a cloud provider to create a cluster.
- Add query param to :new cluster view to display a specific cluster
provider form depending on the value of the provider query param.
- Update unit tests and e2e tests to reflect these changes
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/admin/clusters_controller_spec.rb | 19 | ||||
-rw-r--r-- | spec/controllers/groups/clusters_controller_spec.rb | 19 | ||||
-rw-r--r-- | spec/controllers/projects/clusters_controller_spec.rb | 23 |
3 files changed, 55 insertions, 6 deletions
diff --git a/spec/controllers/admin/clusters_controller_spec.rb b/spec/controllers/admin/clusters_controller_spec.rb index e5501535875..afc059d7561 100644 --- a/spec/controllers/admin/clusters_controller_spec.rb +++ b/spec/controllers/admin/clusters_controller_spec.rb @@ -73,8 +73,8 @@ describe Admin::ClustersController do end describe 'GET #new' do - def get_new - get :new + def get_new(provider: 'gke') + get :new, params: { provider: provider } end describe 'functionality for new cluster' do @@ -85,6 +85,7 @@ describe Admin::ClustersController do end before do + stub_feature_flags(create_eks_clusters: false) allow(SecureRandom).to receive(:hex).and_return(key) end @@ -94,6 +95,20 @@ describe Admin::ClustersController do expect(assigns(:authorize_url)).to include(key) expect(session[session_key_for_redirect_uri]).to eq(new_admin_cluster_path) end + + context 'when create_eks_clusters feature flag is enabled' do + before do + stub_feature_flags(create_eks_clusters: true) + end + + context 'when selected provider is gke and no valid gcp token exists' do + it 'redirects to gcp authorize_url' do + get_new + + expect(response).to redirect_to(assigns(:authorize_url)) + end + end + end end context 'when omniauth has not configured' do diff --git a/spec/controllers/groups/clusters_controller_spec.rb b/spec/controllers/groups/clusters_controller_spec.rb index 09677b42887..5a3ba51d4df 100644 --- a/spec/controllers/groups/clusters_controller_spec.rb +++ b/spec/controllers/groups/clusters_controller_spec.rb @@ -85,8 +85,8 @@ describe Groups::ClustersController do end describe 'GET new' do - def go - get :new, params: { group_id: group } + def go(provider: 'gke') + get :new, params: { group_id: group, provider: provider } end describe 'functionality for new cluster' do @@ -97,6 +97,7 @@ describe Groups::ClustersController do end before do + stub_feature_flags(create_eks_clusters: false) allow(SecureRandom).to receive(:hex).and_return(key) end @@ -106,6 +107,20 @@ describe Groups::ClustersController do expect(assigns(:authorize_url)).to include(key) expect(session[session_key_for_redirect_uri]).to eq(new_group_cluster_path(group)) end + + context 'when create_eks_clusters feature flag is enabled' do + before do + stub_feature_flags(create_eks_clusters: true) + end + + context 'when selected provider is gke and no valid gcp token exists' do + it 'redirects to gcp authorize_url' do + go + + expect(response).to redirect_to(assigns(:authorize_url)) + end + end + end end context 'when omniauth has not configured' do diff --git a/spec/controllers/projects/clusters_controller_spec.rb b/spec/controllers/projects/clusters_controller_spec.rb index 35cbab57037..8ac72df5d20 100644 --- a/spec/controllers/projects/clusters_controller_spec.rb +++ b/spec/controllers/projects/clusters_controller_spec.rb @@ -79,8 +79,12 @@ describe Projects::ClustersController do end describe 'GET new' do - def go - get :new, params: { namespace_id: project.namespace, project_id: project } + def go(provider: 'gke') + get :new, params: { + namespace_id: project.namespace, + project_id: project, + provider: provider + } end describe 'functionality for new cluster' do @@ -91,6 +95,7 @@ describe Projects::ClustersController do end before do + stub_feature_flags(create_eks_clusters: false) allow(SecureRandom).to receive(:hex).and_return(key) end @@ -100,6 +105,20 @@ describe Projects::ClustersController do expect(assigns(:authorize_url)).to include(key) expect(session[session_key_for_redirect_uri]).to eq(new_project_cluster_path(project)) end + + context 'when create_eks_clusters feature flag is enabled' do + before do + stub_feature_flags(create_eks_clusters: true) + end + + context 'when selected provider is gke and no valid gcp token exists' do + it 'redirects to gcp authorize_url' do + go + + expect(response).to redirect_to(assigns(:authorize_url)) + end + end + end end context 'when omniauth has not configured' do |