diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-11-22 12:31:07 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-11-28 14:47:59 +0300 |
commit | 45f2d0af4173ae8e06b548c4bef1fabe14353c85 (patch) | |
tree | 4036b5f257b0f07a42431a2c2cff41dcbdd28dd1 /spec/features/projects/environments | |
parent | a8e2094c6591336405a90e4185e89752d38965bf (diff) |
Add test suit for platform::kubernetes
Diffstat (limited to 'spec/features/projects/environments')
-rw-r--r-- | spec/features/projects/environments/environment_spec.rb | 51 | ||||
-rw-r--r-- | spec/features/projects/environments/environments_spec.rb | 33 |
2 files changed, 55 insertions, 29 deletions
diff --git a/spec/features/projects/environments/environment_spec.rb b/spec/features/projects/environments/environment_spec.rb index 5fc3ba54f65..3d64b404a84 100644 --- a/spec/features/projects/environments/environment_spec.rb +++ b/spec/features/projects/environments/environment_spec.rb @@ -101,35 +101,48 @@ feature 'Environment' do end context 'with terminal' do - let(:project) { create(:kubernetes_project, :test_repo) } + shared_examples 'correct behavior with terminal' do + context 'for project master' do + let(:role) { :master } - context 'for project master' do - let(:role) { :master } + scenario 'it shows the terminal button' do + expect(page).to have_terminal_button + end - scenario 'it shows the terminal button' do - expect(page).to have_terminal_button + context 'web terminal', :js do + before do + # Stub #terminals as it causes js-enabled feature specs to render the page incorrectly + allow_any_instance_of(Environment).to receive(:terminals) { nil } + visit terminal_project_environment_path(project, environment) + end + + it 'displays a web terminal' do + expect(page).to have_selector('#terminal') + expect(page).to have_link(nil, href: environment.external_url) + end + end end - context 'web terminal', :js do - before do - # Stub #terminals as it causes js-enabled feature specs to render the page incorrectly - allow_any_instance_of(Environment).to receive(:terminals) { nil } - visit terminal_project_environment_path(project, environment) - end + context 'for developer' do + let(:role) { :developer } - it 'displays a web terminal' do - expect(page).to have_selector('#terminal') - expect(page).to have_link(nil, href: environment.external_url) + scenario 'does not show terminal button' do + expect(page).not_to have_terminal_button end end end - context 'for developer' do - let(:role) { :developer } + context 'when user configured kubernetes from Integration > Kubernetes' do + let(:project) { create(:kubernetes_project, :test_repo) } - scenario 'does not show terminal button' do - expect(page).not_to have_terminal_button - end + it_behaves_like 'correct behavior with terminal' + end + + context 'when user configured kubernetes from CI/CD > Clusters' do + let!(:cluster) { create(:cluster, :project, :provided_by_gcp) } + let(:project) { cluster.project } + + it_behaves_like 'correct behavior with terminal' end end diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb index 879ee6f4b9b..1732d7f2a9f 100644 --- a/spec/features/projects/environments/environments_spec.rb +++ b/spec/features/projects/environments/environments_spec.rb @@ -208,22 +208,35 @@ feature 'Environments page', :js do end context 'when kubernetes terminal is available' do - let(:project) { create(:kubernetes_project, :test_repo) } + shared_examples 'correct behavior with terminal' do + context 'for project master' do + let(:role) { :master } - context 'for project master' do - let(:role) { :master } + it 'shows the terminal button' do + expect(page).to have_terminal_button + end + end + + context 'when user is a developer' do + let(:role) { :developer } - it 'shows the terminal button' do - expect(page).to have_terminal_button + it 'does not show terminal button' do + expect(page).not_to have_terminal_button + end end end + + context 'when user configured kubernetes from Integration > Kubernetes' do + let(:project) { create(:kubernetes_project, :test_repo) } - context 'when user is a developer' do - let(:role) { :developer } + it_behaves_like 'correct behavior with terminal' + end - it 'does not show terminal button' do - expect(page).not_to have_terminal_button - end + context 'when user configured kubernetes from CI/CD > Clusters' do + let!(:cluster) { create(:cluster, :project, :provided_by_gcp) } + let(:project) { cluster.project } + + it_behaves_like 'correct behavior with terminal' end end end |