Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/projects/settings')
-rw-r--r--spec/features/projects/settings/merge_requests_settings_spec.rb261
-rw-r--r--spec/features/projects/settings/registry_settings_cleanup_tags_spec.rb81
-rw-r--r--spec/features/projects/settings/registry_settings_spec.rb44
-rw-r--r--spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb41
-rw-r--r--spec/features/projects/settings/visibility_settings_spec.rb20
-rw-r--r--spec/features/projects/settings/webhooks_settings_spec.rb6
6 files changed, 388 insertions, 65 deletions
diff --git a/spec/features/projects/settings/merge_requests_settings_spec.rb b/spec/features/projects/settings/merge_requests_settings_spec.rb
new file mode 100644
index 00000000000..ba84d8b6d1a
--- /dev/null
+++ b/spec/features/projects/settings/merge_requests_settings_spec.rb
@@ -0,0 +1,261 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'Projects > Settings > Merge requests' do
+ include ProjectForksHelper
+
+ let(:user) { create(:user) }
+ let(:project) { create(:project, :public, namespace: user.namespace, path: 'gitlab', name: 'sample') }
+
+ before do
+ sign_in(user)
+
+ visit(project_settings_merge_requests_path(project))
+ end
+
+ it 'shows "Merge commit" strategy' do
+ page.within '.merge-request-settings-form' do
+ expect(page).to have_content 'Merge commit'
+ end
+ end
+
+ it 'shows "Merge commit with semi-linear history " strategy' do
+ page.within '.merge-request-settings-form' do
+ expect(page).to have_content 'Merge commit with semi-linear history'
+ end
+ end
+
+ it 'shows "Fast-forward merge" strategy' do
+ page.within '.merge-request-settings-form' do
+ expect(page).to have_content 'Fast-forward merge'
+ end
+ end
+
+ it 'shows Squash commit options', :aggregate_failures do
+ page.within '.merge-request-settings-form' do
+ expect(page).to have_content 'Do not allow'
+ expect(page).to have_content 'Squashing is never performed and the checkbox is hidden.'
+
+ expect(page).to have_content 'Allow'
+ expect(page).to have_content 'Checkbox is visible and unselected by default.'
+
+ expect(page).to have_content 'Encourage'
+ expect(page).to have_content 'Checkbox is visible and selected by default.'
+
+ expect(page).to have_content 'Require'
+ end
+ end
+
+ context 'when Merge Request and Pipelines are initially enabled', :js do
+ context 'when Pipelines are initially enabled' do
+ it 'shows the Merge Requests settings' do
+ expect(page).to have_content 'Pipelines must succeed'
+ expect(page).to have_content 'All threads must be resolved'
+
+ visit edit_project_path(project)
+
+ within('.sharing-permissions-form') do
+ within('[data-for="project[project_feature_attributes][merge_requests_access_level]"]') do
+ find('.gl-toggle').click
+ end
+ end
+
+ find('[data-testid="project-features-save-button"]').send_keys(:return)
+
+ visit project_settings_merge_requests_path(project)
+
+ expect(page).to have_content('Not Found')
+ end
+ end
+
+ context 'when Pipelines are initially disabled', :js do
+ before do
+ project.project_feature.update_attribute('builds_access_level', ProjectFeature::DISABLED)
+
+ visit project_settings_merge_requests_path(project)
+ end
+
+ it 'shows the Merge Requests settings that do not depend on Builds feature' do
+ expect(page).to have_content 'Pipelines must succeed'
+ expect(page).to have_content 'All threads must be resolved'
+
+ visit edit_project_path(project)
+
+ within('.sharing-permissions-form') do
+ within('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"]') do
+ find('.gl-toggle').click
+ end
+ end
+
+ find('[data-testid="project-features-save-button"]').send_keys(:return)
+
+ visit project_settings_merge_requests_path(project)
+
+ expect(page).to have_content 'Pipelines must succeed'
+ expect(page).to have_content 'All threads must be resolved'
+ end
+ end
+ end
+
+ context 'when Merge Request are initially disabled', :js do
+ before do
+ project.project_feature.update_attribute('merge_requests_access_level', ProjectFeature::DISABLED)
+
+ visit(project_settings_merge_requests_path(project))
+ end
+
+ it 'does not show the Merge Requests settings' do
+ expect(page).to have_content('Not Found')
+
+ visit edit_project_path(project)
+
+ within('.sharing-permissions-form') do
+ within('[data-for="project[project_feature_attributes][merge_requests_access_level]"]') do
+ find('.gl-toggle').click
+ end
+ end
+
+ find('[data-testid="project-features-save-button"]').send_keys(:return)
+
+ visit project_settings_merge_requests_path(project)
+
+ expect(page).to have_content 'Pipelines must succeed'
+ expect(page).to have_content 'All threads must be resolved'
+ end
+ end
+
+ describe 'Checkbox to enable merge request link', :js do
+ it 'is initially checked' do
+ checkbox = find_field('project_printing_merge_request_link_enabled')
+ expect(checkbox).to be_checked
+ end
+
+ it 'when unchecked sets :printing_merge_request_link_enabled to false' do
+ uncheck('project_printing_merge_request_link_enabled')
+ within('.merge-request-settings-form') do
+ find('.rspec-save-merge-request-changes')
+ click_on('Save changes')
+ end
+
+ find('.flash-notice')
+ checkbox = find_field('project_printing_merge_request_link_enabled')
+
+ expect(checkbox).not_to be_checked
+
+ project.reload
+ expect(project.printing_merge_request_link_enabled).to be(false)
+ end
+ end
+
+ describe 'Checkbox to remove source branch after merge', :js do
+ it 'is initially checked' do
+ checkbox = find_field('project_remove_source_branch_after_merge')
+ expect(checkbox).to be_checked
+ end
+
+ it 'when unchecked sets :remove_source_branch_after_merge to false' do
+ uncheck('project_remove_source_branch_after_merge')
+ within('.merge-request-settings-form') do
+ find('.rspec-save-merge-request-changes')
+ click_on('Save changes')
+ end
+
+ find('.flash-notice')
+ checkbox = find_field('project_remove_source_branch_after_merge')
+
+ expect(checkbox).not_to be_checked
+
+ project.reload
+ expect(project.remove_source_branch_after_merge).to be(false)
+ end
+ end
+
+ describe 'Squash commits when merging', :js do
+ it 'initially has :squash_option set to :default_off' do
+ radio = find_field('project_project_setting_attributes_squash_option_default_off')
+ expect(radio).to be_checked
+ end
+
+ it 'allows :squash_option to be set to :default_on' do
+ choose('project_project_setting_attributes_squash_option_default_on')
+
+ within('.merge-request-settings-form') do
+ find('.rspec-save-merge-request-changes')
+ click_on('Save changes')
+ end
+
+ wait_for_requests
+
+ radio = find_field('project_project_setting_attributes_squash_option_default_on')
+
+ expect(radio).to be_checked
+ expect(project.reload.project_setting.squash_option).to eq('default_on')
+ end
+
+ it 'allows :squash_option to be set to :always' do
+ choose('project_project_setting_attributes_squash_option_always')
+
+ within('.merge-request-settings-form') do
+ find('.rspec-save-merge-request-changes')
+ click_on('Save changes')
+ end
+
+ wait_for_requests
+
+ radio = find_field('project_project_setting_attributes_squash_option_always')
+
+ expect(radio).to be_checked
+ expect(project.reload.project_setting.squash_option).to eq('always')
+ end
+
+ it 'allows :squash_option to be set to :never' do
+ choose('project_project_setting_attributes_squash_option_never')
+
+ within('.merge-request-settings-form') do
+ find('.rspec-save-merge-request-changes')
+ click_on('Save changes')
+ end
+
+ wait_for_requests
+
+ radio = find_field('project_project_setting_attributes_squash_option_never')
+
+ expect(radio).to be_checked
+ expect(project.reload.project_setting.squash_option).to eq('never')
+ end
+ end
+
+ describe 'target project settings' do
+ context 'when project is a fork' do
+ let_it_be(:upstream) { create(:project, :public) }
+
+ let(:project) { fork_project(upstream, user) }
+
+ it 'allows to change merge request target project behavior' do
+ expect(page).to have_content 'The default target project for merge requests'
+
+ radio = find_field('project_project_setting_attributes_mr_default_target_self_false')
+ expect(radio).to be_checked
+
+ choose('project_project_setting_attributes_mr_default_target_self_true')
+
+ within('.merge-request-settings-form') do
+ find('.rspec-save-merge-request-changes')
+ click_on('Save changes')
+ end
+
+ wait_for_requests
+
+ radio = find_field('project_project_setting_attributes_mr_default_target_self_true')
+
+ expect(radio).to be_checked
+ expect(project.reload.project_setting.mr_default_target_self).to be_truthy
+ end
+ end
+
+ it 'does not show target project section' do
+ expect(page).not_to have_content 'The default target project for merge requests'
+ end
+ end
+end
diff --git a/spec/features/projects/settings/registry_settings_cleanup_tags_spec.rb b/spec/features/projects/settings/registry_settings_cleanup_tags_spec.rb
index 5a50b3de772..477c4c2e1ba 100644
--- a/spec/features/projects/settings/registry_settings_cleanup_tags_spec.rb
+++ b/spec/features/projects/settings/registry_settings_cleanup_tags_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe 'Project > Settings > Packages & Registries > Container registry tag expiration policy' do
+RSpec.describe 'Project > Settings > Packages and registries > Container registry tag expiration policy' do
let_it_be(:user) { create(:user) }
let_it_be(:project, reload: true) { create(:project, namespace: user.namespace) }
@@ -20,10 +20,89 @@ RSpec.describe 'Project > Settings > Packages & Registries > Container registry
end
context 'as owner', :js do
+ it 'shows active tab on sidebar' do
+ subject
+
+ expect(find('.sidebar-top-level-items > li.active')).to have_content('Settings')
+ expect(find('.sidebar-sub-level-items > li.active:not(.fly-out-top-item)'))
+ .to have_content('Packages and registries')
+ end
+
it 'shows available section' do
subject
expect(find('.breadcrumbs')).to have_content('Clean up image tags')
+
+ section = find('[data-testid="container-expiration-policy-project-settings"]')
+ expect(section).to have_text 'Clean up image tags'
+ end
+
+ it 'saves cleanup policy submit the form' do
+ subject
+
+ within '[data-testid="container-expiration-policy-project-settings"]' do
+ select('Every day', from: 'Run cleanup')
+ select('50 tags per image name', from: 'Keep the most recent:')
+ fill_in('Keep tags matching:', with: 'stable')
+ select('7 days', from: 'Remove tags older than:')
+ fill_in('Remove tags matching:', with: '.*-production')
+
+ submit_button = find('[data-testid="save-button"')
+ expect(submit_button).not_to be_disabled
+ submit_button.click
+ end
+
+ expect(page).to have_current_path(project_settings_packages_and_registries_path(project))
+ expect(find('.gl-alert-body')).to have_content('Cleanup policy successfully saved.')
+ end
+
+ it 'does not save cleanup policy submit form with invalid regex' do
+ subject
+
+ within '[data-testid="container-expiration-policy-project-settings"]' do
+ fill_in('Remove tags matching:', with: '*-production')
+
+ submit_button = find('[data-testid="save-button"')
+ expect(submit_button).not_to be_disabled
+ submit_button.click
+ end
+
+ expect(find('.gl-toast')).to have_content('Something went wrong while updating the cleanup policy.')
+ end
+ end
+
+ context 'with a project without expiration policy', :js do
+ before do
+ project.container_expiration_policy.destroy!
+ end
+
+ context 'with container_expiration_policies_enable_historic_entries enabled' do
+ before do
+ stub_application_setting(container_expiration_policies_enable_historic_entries: true)
+ end
+
+ it 'displays the related section' do
+ subject
+
+ within '[data-testid="container-expiration-policy-project-settings"]' do
+ expect(find('[data-testid="enable-toggle"]'))
+ .to have_content('Disabled - Tags will not be automatically deleted.')
+ end
+ end
+ end
+
+ context 'with container_expiration_policies_enable_historic_entries disabled' do
+ before do
+ stub_application_setting(container_expiration_policies_enable_historic_entries: false)
+ end
+
+ it 'does not display the related section' do
+ subject
+
+ within '[data-testid="container-expiration-policy-project-settings"]' do
+ expect(find('.gl-alert-title')).to have_content('Cleanup policy for tags is disabled')
+ end
+ end
end
end
diff --git a/spec/features/projects/settings/registry_settings_spec.rb b/spec/features/projects/settings/registry_settings_spec.rb
index 1fb46c669e7..d64570cd5cc 100644
--- a/spec/features/projects/settings/registry_settings_spec.rb
+++ b/spec/features/projects/settings/registry_settings_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe 'Project > Settings > Packages & Registries > Container registry tag expiration policy', :js do
+RSpec.describe 'Project > Settings > Packages and registries > Container registry tag expiration policy' do
let_it_be(:user) { create(:user) }
let_it_be(:project, reload: true) { create(:project, namespace: user.namespace) }
@@ -19,48 +19,30 @@ RSpec.describe 'Project > Settings > Packages & Registries > Container registry
stub_container_registry_config(enabled: container_registry_enabled)
end
- context 'as owner' do
- it 'shows available section' do
+ context 'as owner', :js do
+ it 'shows active tab on sidebar' do
subject
- settings_block = find('[data-testid="container-expiration-policy-project-settings"]')
- expect(settings_block).to have_text 'Clean up image tags'
+ expect(find('.sidebar-top-level-items > li.active')).to have_content('Settings')
+ expect(find('.sidebar-sub-level-items > li.active:not(.fly-out-top-item)'))
+ .to have_content('Packages and registries')
end
- it 'saves cleanup policy submit the form' do
+ it 'shows available section' do
subject
- within '[data-testid="container-expiration-policy-project-settings"]' do
- select('Every day', from: 'Run cleanup')
- select('50 tags per image name', from: 'Keep the most recent:')
- fill_in('Keep tags matching:', with: 'stable')
- select('7 days', from: 'Remove tags older than:')
- fill_in('Remove tags matching:', with: '.*-production')
-
- submit_button = find('[data-testid="save-button"')
- expect(submit_button).not_to be_disabled
- submit_button.click
- end
-
- expect(find('.gl-toast')).to have_content('Cleanup policy successfully saved.')
+ settings_block = find('[data-testid="container-expiration-policy-project-settings"]')
+ expect(settings_block).to have_text 'Clean up image tags'
end
- it 'does not save cleanup policy submit form with invalid regex' do
+ it 'contains link to clean up image tags page' do
subject
- within '[data-testid="container-expiration-policy-project-settings"]' do
- fill_in('Remove tags matching:', with: '*-production')
-
- submit_button = find('[data-testid="save-button"')
- expect(submit_button).not_to be_disabled
- submit_button.click
- end
-
- expect(find('.gl-toast')).to have_content('Something went wrong while updating the cleanup policy.')
+ expect(page).to have_link('Edit cleanup rules', href: cleanup_image_tags_project_settings_packages_and_registries_path(project))
end
end
- context 'with a project without expiration policy' do
+ context 'with a project without expiration policy', :js do
before do
project.container_expiration_policy.destroy!
end
@@ -74,7 +56,7 @@ RSpec.describe 'Project > Settings > Packages & Registries > Container registry
subject
within '[data-testid="container-expiration-policy-project-settings"]' do
- expect(find('[data-testid="enable-toggle"]')).to have_content('Disabled - Tags will not be automatically deleted.')
+ expect(page).to have_link('Set cleanup rules', href: cleanup_image_tags_project_settings_packages_and_registries_path(project))
end
end
end
diff --git a/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb b/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb
index 6aa59f72d2a..c76b4d0af88 100644
--- a/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb
+++ b/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb
@@ -9,29 +9,29 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do
before do
sign_in(user)
- visit edit_project_path(project)
+ visit project_settings_merge_requests_path(project)
end
it 'shows "Merge commit" strategy' do
- page.within '#js-merge-request-settings' do
+ page.within '.merge-request-settings-form' do
expect(page).to have_content 'Merge commit'
end
end
it 'shows "Merge commit with semi-linear history " strategy' do
- page.within '#js-merge-request-settings' do
+ page.within '.merge-request-settings-form' do
expect(page).to have_content 'Merge commit with semi-linear history'
end
end
it 'shows "Fast-forward merge" strategy' do
- page.within '#js-merge-request-settings' do
+ page.within '.merge-request-settings-form' do
expect(page).to have_content 'Fast-forward merge'
end
end
it 'shows Squash commit options', :aggregate_failures do
- page.within '#js-merge-request-settings' do
+ page.within '.merge-request-settings-form' do
expect(page).to have_content 'Do not allow'
expect(page).to have_content 'Squashing is never performed and the checkbox is hidden.'
@@ -52,30 +52,33 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do
expect(page).to have_content 'Pipelines must succeed'
expect(page).to have_content 'All threads must be resolved'
- within('.sharing-permissions-form') do
- find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .gl-toggle').click
- find('[data-testid="project-features-save-button"]').send_keys(:return)
- end
+ visit edit_project_path(project)
+
+ find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .gl-toggle').click
+ find('[data-testid="project-features-save-button"]').send_keys(:return)
+
+ visit project_settings_merge_requests_path(project)
- expect(page).not_to have_content 'Pipelines must succeed'
- expect(page).not_to have_content 'All threads must be resolved'
+ expect(page).to have_content "Page Not Found"
end
end
context 'when Pipelines are initially disabled', :js do
before do
project.project_feature.update_attribute('builds_access_level', ProjectFeature::DISABLED)
- visit edit_project_path(project)
+ visit project_settings_merge_requests_path(project)
end
it 'shows the Merge Requests settings that do not depend on Builds feature' do
expect(page).to have_content 'Pipelines must succeed'
expect(page).to have_content 'All threads must be resolved'
- within('.sharing-permissions-form') do
- find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .gl-toggle').click
- find('[data-testid="project-features-save-button"]').send_keys(:return)
- end
+ visit edit_project_path(project)
+
+ find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .gl-toggle').click
+ find('[data-testid="project-features-save-button"]').send_keys(:return)
+
+ visit project_settings_merge_requests_path(project)
expect(page).to have_content 'Pipelines must succeed'
expect(page).to have_content 'All threads must be resolved'
@@ -86,18 +89,22 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do
context 'when Merge Request are initially disabled', :js do
before do
project.project_feature.update_attribute('merge_requests_access_level', ProjectFeature::DISABLED)
- visit edit_project_path(project)
+ visit project_settings_merge_requests_path(project)
end
it 'does not show the Merge Requests settings' do
expect(page).not_to have_content 'Pipelines must succeed'
expect(page).not_to have_content 'All threads must be resolved'
+ visit edit_project_path(project)
+
within('.sharing-permissions-form') do
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .gl-toggle').click
find('[data-testid="project-features-save-button"]').send_keys(:return)
end
+ visit project_settings_merge_requests_path(project)
+
expect(page).to have_content 'Pipelines must succeed'
expect(page).to have_content 'All threads must be resolved'
end
diff --git a/spec/features/projects/settings/visibility_settings_spec.rb b/spec/features/projects/settings/visibility_settings_spec.rb
index fc78b5b5769..5cb12544066 100644
--- a/spec/features/projects/settings/visibility_settings_spec.rb
+++ b/spec/features/projects/settings/visibility_settings_spec.rb
@@ -28,26 +28,12 @@ RSpec.describe 'Projects > Settings > Visibility settings', :js do
expect(visibility_select_container).to have_content 'Only accessible by project members. Membership must be explicitly granted to each user.'
end
- context 'merge requests select' do
- it 'hides merge requests section' do
- find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .gl-toggle').click
-
- expect(page).to have_selector('.merge-requests-feature', visible: false)
- end
-
- context 'given project with merge_requests_disabled access level' do
- let(:project) { create(:project, :merge_requests_disabled, namespace: user.namespace) }
-
- it 'hides merge requests section' do
- expect(page).to have_selector('.merge-requests-feature', visible: false)
- end
- end
- end
-
context 'builds select' do
it 'hides builds select section' do
find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .gl-toggle').click
+ visit project_settings_merge_requests_path(project)
+
expect(page).to have_selector('.builds-feature', visible: false)
end
@@ -55,6 +41,8 @@ RSpec.describe 'Projects > Settings > Visibility settings', :js do
let(:project) { create(:project, :builds_disabled, namespace: user.namespace) }
it 'hides builds select section' do
+ visit project_settings_merge_requests_path(project)
+
expect(page).to have_selector('.builds-feature', visible: false)
end
end
diff --git a/spec/features/projects/settings/webhooks_settings_spec.rb b/spec/features/projects/settings/webhooks_settings_spec.rb
index c84de7fc03f..d525544ac15 100644
--- a/spec/features/projects/settings/webhooks_settings_spec.rb
+++ b/spec/features/projects/settings/webhooks_settings_spec.rb
@@ -139,6 +139,12 @@ RSpec.describe 'Projects > Settings > Webhook Settings' do
expect(page).to have_current_path(edit_project_hook_path(project, hook), ignore_query: true)
end
+
+ it 'does not show search settings on the hook log details' do
+ visit project_hook_hook_log_path(project, hook, hook_log)
+
+ expect(page).not_to have_field(placeholder: 'Search settings', disabled: true)
+ end
end
end
end