diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-09-18 22:20:43 +0300 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2018-09-18 22:20:43 +0300 |
commit | d236a6c2b2e22199367c6e17c470523b587374ab (patch) | |
tree | 30c38895821994be8a24f0edbc0d555a8519b5d1 /spec/features | |
parent | 354f0bccbf8d530fbb5a1eb2b3cea931c644cc59 (diff) |
Resolve "Enable Auto DevOps by default for self managed instances of GitLab"
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/projects/pipelines/pipelines_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb | 184 |
2 files changed, 101 insertions, 85 deletions
diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index 26a92f14787..41822babbc9 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -9,6 +9,7 @@ describe 'Pipelines', :js do before do sign_in(user) project.add_developer(user) + project.update!(auto_devops_attributes: { enabled: false }) end describe 'GET /:project/pipelines' do @@ -641,6 +642,7 @@ describe 'Pipelines', :js do context 'when user is not logged in' do before do + project.update!(auto_devops_attributes: { enabled: false }) visit project_pipelines_path(project) end diff --git a/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb index b8326edd4fd..6fe21579e8e 100644 --- a/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb +++ b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb @@ -28,8 +28,6 @@ describe 'Projects > Show > User sees setup shortcut buttons' do end it '"Auto DevOps enabled" button not linked' do - project.create_auto_devops!(enabled: true) - visit project_path(project) page.within('.project-stats') do @@ -65,19 +63,23 @@ describe 'Projects > Show > User sees setup shortcut buttons' do end describe 'Auto DevOps button' do - it '"Enable Auto DevOps" button linked to settings page' do - page.within('.project-stats') do - expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) + context 'when Auto DevOps is enabled' do + it '"Auto DevOps enabled" anchor linked to settings page' do + visit project_path(project) + + page.within('.project-stats') do + expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) + end end end - it '"Auto DevOps enabled" anchor linked to settings page' do - project.create_auto_devops!(enabled: true) - - visit project_path(project) + context 'when Auto DevOps is not enabled' do + let(:project) { create(:project, :public, :empty_repo, auto_devops_attributes: { enabled: false }) } - page.within('.project-stats') do - expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) + it '"Enable Auto DevOps" button linked to settings page' do + page.within('.project-stats') do + expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) + end end end end @@ -113,27 +115,31 @@ describe 'Projects > Show > User sees setup shortcut buttons' do visit project_path(project) end - it 'no Auto DevOps button if can not manage pipelines' do - page.within('.project-stats') do - expect(page).not_to have_link('Enable Auto DevOps') - expect(page).not_to have_link('Auto DevOps enabled') + context 'when Auto DevOps is enabled' do + it '"Auto DevOps enabled" button not linked' do + visit project_path(project) + + page.within('.project-stats') do + expect(page).to have_text('Auto DevOps enabled') + end end end - it '"Auto DevOps enabled" button not linked' do - project.create_auto_devops!(enabled: true) - - visit project_path(project) + context 'when Auto DevOps is not enabled' do + let(:project) { create(:project, :public, :repository, auto_devops_attributes: { enabled: false }) } - page.within('.project-stats') do - expect(page).to have_text('Auto DevOps enabled') + it 'no Auto DevOps button if can not manage pipelines' do + page.within('.project-stats') do + expect(page).not_to have_link('Enable Auto DevOps') + expect(page).not_to have_link('Auto DevOps enabled') + end end - end - it 'no Kubernetes cluster button if can not manage clusters' do - page.within('.project-stats') do - expect(page).not_to have_link('Add Kubernetes cluster') - expect(page).not_to have_link('Kubernetes configured') + it 'no Kubernetes cluster button if can not manage clusters' do + page.within('.project-stats') do + expect(page).not_to have_link('Add Kubernetes cluster') + expect(page).not_to have_link('Kubernetes configured') + end end end end @@ -222,97 +228,105 @@ describe 'Projects > Show > User sees setup shortcut buttons' do end describe 'GitLab CI configuration button' do - it '"Set up CI/CD" button linked to new file populated for a .gitlab-ci.yml' do - visit project_path(project) - - expect(project.repository.gitlab_ci_yml).to be_nil + context 'when Auto DevOps is enabled' do + it 'no "Set up CI/CD" button if the project has Auto DevOps enabled' do + visit project_path(project) - page.within('.project-stats') do - expect(page).to have_link('Set up CI/CD', href: presenter.add_ci_yml_path) + page.within('.project-stats') do + expect(page).not_to have_link('Set up CI/CD') + end end end - it 'no "Set up CI/CD" button if the project already has a .gitlab-ci.yml' do - Files::CreateService.new( - project, - project.creator, - start_branch: 'master', - branch_name: 'master', - commit_message: "Add .gitlab-ci.yml", - file_path: '.gitlab-ci.yml', - file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) - ).execute + context 'when Auto DevOps is not enabled' do + let(:project) { create(:project, :public, :repository, auto_devops_attributes: { enabled: false }) } - expect(project.repository.gitlab_ci_yml).not_to be_nil + it '"Set up CI/CD" button linked to new file populated for a .gitlab-ci.yml' do + visit project_path(project) - visit project_path(project) + expect(project.repository.gitlab_ci_yml).to be_nil - page.within('.project-stats') do - expect(page).not_to have_link('Set up CI/CD') + page.within('.project-stats') do + expect(page).to have_link('Set up CI/CD', href: presenter.add_ci_yml_path) + end end - end - it 'no "Set up CI/CD" button if the project has Auto DevOps enabled' do - project.create_auto_devops!(enabled: true) + it 'no "Set up CI/CD" button if the project already has a .gitlab-ci.yml' do + Files::CreateService.new( + project, + project.creator, + start_branch: 'master', + branch_name: 'master', + commit_message: "Add .gitlab-ci.yml", + file_path: '.gitlab-ci.yml', + file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) + ).execute - visit project_path(project) + expect(project.repository.gitlab_ci_yml).not_to be_nil - page.within('.project-stats') do - expect(page).not_to have_link('Set up CI/CD') + visit project_path(project) + + page.within('.project-stats') do + expect(page).not_to have_link('Set up CI/CD') + end end end end describe 'Auto DevOps button' do - it '"Enable Auto DevOps" button linked to settings page' do - visit project_path(project) + context 'when Auto DevOps is enabled' do + it '"Auto DevOps enabled" anchor linked to settings page' do + visit project_path(project) - page.within('.project-stats') do - expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) + page.within('.project-stats') do + expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) + end end end - it '"Enable Auto DevOps" button linked to settings page' do - project.create_auto_devops!(enabled: true) + context 'when Auto DevOps is not enabled' do + let(:project) { create(:project, :public, :repository, auto_devops_attributes: { enabled: false }) } - visit project_path(project) + it '"Enable Auto DevOps" button linked to settings page' do + visit project_path(project) - page.within('.project-stats') do - expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) + page.within('.project-stats') do + expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) + end end - end - it 'no Auto DevOps button if Auto DevOps callout is shown' do - allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(true) + it 'no Auto DevOps button if Auto DevOps callout is shown' do + allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(true) - visit project_path(project) + visit project_path(project) - expect(page).to have_selector('.js-autodevops-banner') + expect(page).to have_selector('.js-autodevops-banner') - page.within('.project-stats') do - expect(page).not_to have_link('Enable Auto DevOps') - expect(page).not_to have_link('Auto DevOps enabled') + page.within('.project-stats') do + expect(page).not_to have_link('Enable Auto DevOps') + expect(page).not_to have_link('Auto DevOps enabled') + end end - end - it 'no "Enable Auto DevOps" button when .gitlab-ci.yml already exists' do - Files::CreateService.new( - project, - project.creator, - start_branch: 'master', - branch_name: 'master', - commit_message: "Add .gitlab-ci.yml", - file_path: '.gitlab-ci.yml', - file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) - ).execute + it 'no "Enable Auto DevOps" button when .gitlab-ci.yml already exists' do + Files::CreateService.new( + project, + project.creator, + start_branch: 'master', + branch_name: 'master', + commit_message: "Add .gitlab-ci.yml", + file_path: '.gitlab-ci.yml', + file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) + ).execute - expect(project.repository.gitlab_ci_yml).not_to be_nil + expect(project.repository.gitlab_ci_yml).not_to be_nil - visit project_path(project) + visit project_path(project) - page.within('.project-stats') do - expect(page).not_to have_link('Enable Auto DevOps') - expect(page).not_to have_link('Auto DevOps enabled') + page.within('.project-stats') do + expect(page).not_to have_link('Enable Auto DevOps') + expect(page).not_to have_link('Auto DevOps enabled') + end end end end |