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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-27 18:09:52 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-27 18:09:52 +0300
commita2f36202361dcef1f2c9242929f81a4090b9ce97 (patch)
treeba21b187bf565cde47412e89bb1ccde829672dd9 /spec
parent154523302b10ab5aeb67bde861880a98e3f8117a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/project_variables_spec.rb2
-rw-r--r--spec/features/projects/navbar_spec.rb20
-rw-r--r--spec/features/projects/settings/registry_settings_spec.rb160
-rw-r--r--spec/features/projects/settings/user_manages_project_members_spec.rb26
-rw-r--r--spec/features/users/signup_spec.rb12
-rw-r--r--spec/features/whats_new_spec.rb18
-rw-r--r--spec/fixtures/whats_new/20201225_01_04.yml19
-rw-r--r--spec/helpers/whats_new_helper_spec.rb57
-rw-r--r--spec/lib/gitlab/usage_data_spec.rb3
-rw-r--r--spec/models/application_setting_spec.rb5
-rw-r--r--spec/models/release_highlight_spec.rb50
-rw-r--r--spec/requests/api/settings_spec.rb28
-rw-r--r--spec/requests/whats_new_controller_spec.rb14
-rw-r--r--spec/support/shared_examples/features/variable_list_shared_examples.rb24
14 files changed, 340 insertions, 98 deletions
diff --git a/spec/features/project_variables_spec.rb b/spec/features/project_variables_spec.rb
index 327d8133411..62565eaabe1 100644
--- a/spec/features/project_variables_spec.rb
+++ b/spec/features/project_variables_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe 'Project variables', :js do
it_behaves_like 'variable list'
it 'adds a new variable with an environment scope' do
- click_button('Add Variable')
+ click_button('Add variable')
page.within('#add-ci-variable') do
find('[data-qa-selector="ci_variable_key_field"] input').set('akey')
diff --git a/spec/features/projects/navbar_spec.rb b/spec/features/projects/navbar_spec.rb
index 7dc3ee63669..9bb8f0b2f21 100644
--- a/spec/features/projects/navbar_spec.rb
+++ b/spec/features/projects/navbar_spec.rb
@@ -12,6 +12,7 @@ RSpec.describe 'Project navbar' do
let_it_be(:project) { create(:project, :repository) }
before do
+ stub_feature_flags(sidebar_refactor: false)
insert_package_nav(_('Operations'))
insert_infrastructure_registry_nav
stub_config(registry: { enabled: false })
@@ -69,4 +70,23 @@ RSpec.describe 'Project navbar' do
it_behaves_like 'verified navigation bar'
end
+
+ context 'when sidebar refactor feature flag is on' do
+ before do
+ stub_feature_flags(sidebar_refactor: true)
+ stub_config(registry: { enabled: true })
+
+ insert_container_nav
+
+ insert_after_sub_nav_item(
+ _('Operations'),
+ within: _('Settings'),
+ new_sub_nav_item_name: _('Packages & Registries')
+ )
+
+ visit project_path(project)
+ end
+
+ it_behaves_like 'verified navigation bar'
+ end
end
diff --git a/spec/features/projects/settings/registry_settings_spec.rb b/spec/features/projects/settings/registry_settings_spec.rb
index bc60cdd2f8e..6a2769d11fd 100644
--- a/spec/features/projects/settings/registry_settings_spec.rb
+++ b/spec/features/projects/settings/registry_settings_spec.rb
@@ -11,105 +11,125 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
let(:container_registry_enabled) { true }
let(:container_registry_enabled_on_project) { true }
- subject { visit project_settings_ci_cd_path(project) }
+ shared_examples 'an expiration policy form' do
+ before do
+ project.update!(container_registry_enabled: container_registry_enabled_on_project)
+ project.container_expiration_policy.update!(enabled: true)
- before do
- project.update!(container_registry_enabled: container_registry_enabled_on_project)
- project.container_expiration_policy.update!(enabled: true)
+ sign_in(user)
+ stub_container_registry_config(enabled: container_registry_enabled)
+ end
- sign_in(user)
- stub_container_registry_config(enabled: container_registry_enabled)
- end
+ context 'as owner' do
+ it 'shows available section' do
+ subject
- context 'as owner' do
- it 'shows available section' do
- subject
+ settings_block = find('#js-registry-policies')
+ expect(settings_block).to have_text 'Clean up image tags'
+ end
- settings_block = find('#js-registry-policies')
- expect(settings_block).to have_text 'Clean up image tags'
- end
+ it 'saves cleanup policy submit the form' do
+ subject
- it 'saves cleanup policy submit the form' do
- subject
+ within '#js-registry-policies' 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
- within '#js-registry-policies' 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')
+ expect(find('.gl-toast')).to have_content('Cleanup policy successfully saved.')
+ end
- submit_button = find('[data-testid="save-button"')
- expect(submit_button).not_to be_disabled
- submit_button.click
+ it 'does not save cleanup policy submit form with invalid regex' do
+ subject
+
+ within '#js-registry-policies' 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
- toast = find('.gl-toast')
- expect(toast).to have_content('Cleanup policy successfully saved.')
end
- it 'does not save cleanup policy submit form with invalid regex' do
- subject
+ context 'with a project without expiration policy' do
+ where(:application_setting, :feature_flag, :result) do
+ true | true | :available_section
+ true | false | :available_section
+ false | true | :available_section
+ false | false | :disabled_message
+ end
- within '#js-registry-policies' do
- fill_in('Remove tags matching:', with: '*-production')
+ with_them do
+ before do
+ project.container_expiration_policy.destroy!
+ stub_feature_flags(container_expiration_policies_historic_entry: false)
+ stub_application_setting(container_expiration_policies_enable_historic_entries: application_setting)
+ stub_feature_flags(container_expiration_policies_historic_entry: project) if feature_flag
+ end
- submit_button = find('[data-testid="save-button"')
- expect(submit_button).not_to be_disabled
- submit_button.click
+ it 'displays the expected result' do
+ subject
+
+ within '#js-registry-policies' do
+ case result
+ when :available_section
+ expect(find('[data-testid="enable-toggle"]')).to have_content('Disabled - Tags will not be automatically deleted.')
+ when :disabled_message
+ expect(find('.gl-alert-title')).to have_content('Cleanup policy for tags is disabled')
+ end
+ end
+ end
end
- toast = find('.gl-toast')
- expect(toast).to have_content('Something went wrong while updating the cleanup policy.')
end
- end
- context 'with a project without expiration policy' do
- where(:application_setting, :feature_flag, :result) do
- true | true | :available_section
- true | false | :available_section
- false | true | :available_section
- false | false | :disabled_message
- end
+ context 'when registry is disabled' do
+ let(:container_registry_enabled) { false }
+
+ it 'does not exists' do
+ subject
- with_them do
- before do
- project.container_expiration_policy.destroy!
- stub_feature_flags(container_expiration_policies_historic_entry: false)
- stub_application_setting(container_expiration_policies_enable_historic_entries: application_setting)
- stub_feature_flags(container_expiration_policies_historic_entry: project) if feature_flag
+ expect(page).not_to have_selector('#js-registry-policies')
end
+ end
- it 'displays the expected result' do
+ context 'when container registry is disabled on project' do
+ let(:container_registry_enabled_on_project) { false }
+
+ it 'does not exists' do
subject
- within '#js-registry-policies' do
- case result
- when :available_section
- expect(find('[data-testid="enable-toggle"]')).to have_content('Disabled - Tags will not be automatically deleted.')
- when :disabled_message
- expect(find('.gl-alert-title')).to have_content('Cleanup policy for tags is disabled')
- end
- end
+ expect(page).not_to have_selector('#js-registry-policies')
end
end
end
- context 'when registry is disabled' do
- let(:container_registry_enabled) { false }
+ context 'with sidebar feature flag off' do
+ subject { visit project_settings_ci_cd_path(project) }
- it 'does not exists' do
- subject
-
- expect(page).not_to have_selector('#js-registry-policies')
+ before do
+ stub_feature_flags(sidebar_refactor: false)
end
- end
- context 'when container registry is disabled on project' do
- let(:container_registry_enabled_on_project) { false }
+ it_behaves_like 'an expiration policy form'
+ end
- it 'does not exists' do
- subject
+ context 'with sidebar feature flag on' do
+ subject { visit project_settings_packages_and_registries_path(project) }
- expect(page).not_to have_selector('#js-registry-policies')
+ before do
+ stub_feature_flags(sidebar_refactor: true)
end
+
+ it_behaves_like 'an expiration policy form'
end
end
diff --git a/spec/features/projects/settings/user_manages_project_members_spec.rb b/spec/features/projects/settings/user_manages_project_members_spec.rb
index b237e7e8ce7..5980246944e 100644
--- a/spec/features/projects/settings/user_manages_project_members_spec.rb
+++ b/spec/features/projects/settings/user_manages_project_members_spec.rb
@@ -38,16 +38,12 @@ RSpec.describe 'Projects > Settings > User manages project members' do
end
it 'imports a team from another project', :js do
- stub_feature_flags(invite_members_group_modal: false)
-
project2.add_maintainer(user)
project2.add_reporter(user_mike)
visit(project_project_members_path(project))
- page.within('.invite-users-form') do
- click_link('Import')
- end
+ click_link('Import a project')
select2(project2.id, from: '#source_project_id')
click_button('Import project members')
@@ -55,6 +51,26 @@ RSpec.describe 'Projects > Settings > User manages project members' do
expect(find_member_row(user_mike)).to have_content('Reporter')
end
+ describe 'when the :invite_members_group_modal is disabled' do
+ it 'imports a team from another project', :js do
+ stub_feature_flags(invite_members_group_modal: false)
+
+ project2.add_maintainer(user)
+ project2.add_reporter(user_mike)
+
+ visit(project_project_members_path(project))
+
+ page.within('.invite-users-form') do
+ click_link('Import')
+ end
+
+ select2(project2.id, from: '#source_project_id')
+ click_button('Import project members')
+
+ expect(find_member_row(user_mike)).to have_content('Reporter')
+ end
+ end
+
it 'shows all members of project shared group', :js do
group.add_owner(user)
group.add_developer(user_dmitriy)
diff --git a/spec/features/users/signup_spec.rb b/spec/features/users/signup_spec.rb
index 5f70517224e..17a6abb99e0 100644
--- a/spec/features/users/signup_spec.rb
+++ b/spec/features/users/signup_spec.rb
@@ -57,6 +57,12 @@ RSpec.describe 'Signup' do
fill_in 'new_user_password', with: new_user.password
end
+ def confirm_email
+ new_user_token = User.find_by_email(new_user.email).confirmation_token
+
+ visit user_confirmation_path(confirmation_token: new_user_token)
+ end
+
describe 'username validation', :js do
before do
visit new_user_registration_path
@@ -191,7 +197,7 @@ RSpec.describe 'Signup' do
stub_feature_flags(soft_email_confirmation: false)
end
- it 'creates the user account and sends a confirmation email' do
+ it 'creates the user account and sends a confirmation email, and pre-fills email address after confirming' do
visit new_user_registration_path
fill_in_signup_form
@@ -199,6 +205,10 @@ RSpec.describe 'Signup' do
expect { click_button 'Register' }.to change { User.count }.by(1)
expect(current_path).to eq users_almost_there_path
expect(page).to have_content('Please check your email to confirm your account')
+
+ confirm_email
+
+ expect(find_field('Username or email').value).to eq(new_user.email)
end
end
diff --git a/spec/features/whats_new_spec.rb b/spec/features/whats_new_spec.rb
index 55b96361f03..2938ea1b1e8 100644
--- a/spec/features/whats_new_spec.rb
+++ b/spec/features/whats_new_spec.rb
@@ -34,6 +34,24 @@ RSpec.describe "renders a `whats new` dropdown item" do
sign_in(user)
end
+ it 'renders dropdown item when feature enabled' do
+ Gitlab::CurrentSettings.update!(whats_new_variant: ApplicationSetting.whats_new_variants[:all_tiers])
+
+ visit root_dashboard_path
+ find('.header-help-dropdown-toggle').click
+
+ expect(page).to have_button(text: "What's new")
+ end
+
+ it 'does not render dropdown item when feature disabled' do
+ Gitlab::CurrentSettings.update!(whats_new_variant: ApplicationSetting.whats_new_variants[:disabled])
+
+ visit root_dashboard_path
+ find('.header-help-dropdown-toggle').click
+
+ expect(page).not_to have_button(text: "What's new")
+ end
+
it 'shows notification dot and count and removes it once viewed' do
visit root_dashboard_path
diff --git a/spec/fixtures/whats_new/20201225_01_04.yml b/spec/fixtures/whats_new/20201225_01_04.yml
new file mode 100644
index 00000000000..0dfd0d780c7
--- /dev/null
+++ b/spec/fixtures/whats_new/20201225_01_04.yml
@@ -0,0 +1,19 @@
+---
+- title: View epics on a board
+ body: |
+ ## View epics on a board
+ self-managed: true
+ gitlab-com: false
+ packages: ["Free", "Premium", "Ultimate"]
+- title: View Jira issue details in GitLab
+ body: |
+ ## View Jira issue details in GitLab
+ self-managed: true
+ gitlab-com: false
+ packages: ["Premium", "Ultimate"]
+- title: Integrate any IT alerting tool with GitLab
+ body: |
+ ## Integrate any IT alerting tool with GitLab
+ self-managed: true
+ gitlab-com: false
+ packages: ["Ultimate"] \ No newline at end of file
diff --git a/spec/helpers/whats_new_helper_spec.rb b/spec/helpers/whats_new_helper_spec.rb
index 0e4b4621560..9ae7ef38736 100644
--- a/spec/helpers/whats_new_helper_spec.rb
+++ b/spec/helpers/whats_new_helper_spec.rb
@@ -59,5 +59,62 @@ RSpec.describe WhatsNewHelper do
expect(subject).to be false
end
end
+
+ context 'depending on whats_new_variant' do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:variant, :result) do
+ :all_tiers | true
+ :current_tier | true
+ :disabled | false
+ end
+
+ with_them do
+ it 'returns correct result depending on variant' do
+ allow(Gitlab).to receive(:dev_env_org_or_com?).and_return(true)
+ Gitlab::CurrentSettings.update!(whats_new_variant: ApplicationSetting.whats_new_variants[variant])
+
+ expect(subject).to eq(result)
+ end
+ end
+ end
+ end
+
+ describe '#whats_new_variants' do
+ it 'returns ApplicationSetting.whats_new_variants' do
+ expect(helper.whats_new_variants).to eq(ApplicationSetting.whats_new_variants)
+ end
+ end
+
+ describe '#whats_new_variants_label' do
+ let(:labels) do
+ [
+ helper.whats_new_variants_label('all_tiers'),
+ helper.whats_new_variants_label('current_tier'),
+ helper.whats_new_variants_label('disabled'),
+ helper.whats_new_variants_label(nil)
+ ]
+ end
+
+ it 'returns different labels depending on variant' do
+ expect(labels.uniq.size).to eq(labels.size)
+ expect(labels[3]).to be_nil
+ end
+ end
+
+ describe '#whats_new_variants_description' do
+ let(:descriptions) do
+ [
+ helper.whats_new_variants_description('all_tiers'),
+ helper.whats_new_variants_description('current_tier'),
+ helper.whats_new_variants_description('disabled'),
+ helper.whats_new_variants_description(nil)
+ ]
+ end
+
+ it 'returns different descriptions depending on variant' do
+ expect(descriptions.uniq.size).to eq(descriptions.size)
+ expect(descriptions[3]).to be_nil
+ end
end
end
diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb
index dda033c94b7..42d502b9d23 100644
--- a/spec/lib/gitlab/usage_data_spec.rb
+++ b/spec/lib/gitlab/usage_data_spec.rb
@@ -1303,10 +1303,11 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
'p_analytics_repo' => 123,
'i_analytics_cohorts' => 123,
'i_analytics_dev_ops_score' => 123,
- 'i_analytics_dev_ops_adoption' => 123,
'i_analytics_instance_statistics' => 123,
'p_analytics_merge_request' => 123,
'g_analytics_merge_request' => 123,
+ 'i_analytics_dev_ops_adoption' => 123,
+ 'users_viewing_analytics_group_devops_adoption' => 123,
'analytics_unique_visits_for_any_target' => 543,
'analytics_unique_visits_for_any_target_monthly' => 987
}
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index 4b0731e0720..c7d05b64235 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -129,6 +129,11 @@ RSpec.describe ApplicationSetting do
it { is_expected.not_to allow_value(nil).for(:notes_create_limit_allowlist) }
it { is_expected.to allow_value([]).for(:notes_create_limit_allowlist) }
+ it { is_expected.to allow_value('all_tiers').for(:whats_new_variant) }
+ it { is_expected.to allow_value('current_tier').for(:whats_new_variant) }
+ it { is_expected.to allow_value('disabled').for(:whats_new_variant) }
+ it { is_expected.not_to allow_value(nil).for(:whats_new_variant) }
+
context 'help_page_documentation_base_url validations' do
it { is_expected.to allow_value(nil).for(:help_page_documentation_base_url) }
it { is_expected.to allow_value('https://docs.gitlab.com').for(:help_page_documentation_base_url) }
diff --git a/spec/models/release_highlight_spec.rb b/spec/models/release_highlight_spec.rb
index 673451b5e76..b4dff4c33ff 100644
--- a/spec/models/release_highlight_spec.rb
+++ b/spec/models/release_highlight_spec.rb
@@ -7,6 +7,7 @@ RSpec.describe ReleaseHighlight, :clean_gitlab_redis_cache do
before do
allow(Dir).to receive(:glob).with(Rails.root.join('data', 'whats_new', '*.yml')).and_return(fixture_dir_glob)
+ Gitlab::CurrentSettings.update!(whats_new_variant: ApplicationSetting.whats_new_variants[:all_tiers])
end
after do
@@ -24,16 +25,16 @@ RSpec.describe ReleaseHighlight, :clean_gitlab_redis_cache do
subject { ReleaseHighlight.paginated(page: page) }
context 'when there is another page of results' do
- let(:page) { 2 }
+ let(:page) { 3 }
it 'responds with paginated results' do
expect(subject[:items].first['title']).to eq('bright')
- expect(subject[:next_page]).to eq(3)
+ expect(subject[:next_page]).to eq(4)
end
end
context 'when there is NOT another page of results' do
- let(:page) { 3 }
+ let(:page) { 4 }
it 'responds with paginated results and no next_page' do
expect(subject[:items].first['title']).to eq("It's gonna be a bright")
@@ -54,8 +55,8 @@ RSpec.describe ReleaseHighlight, :clean_gitlab_redis_cache do
subject { ReleaseHighlight.paginated }
it 'uses multiple levels of cache' do
- expect(Rails.cache).to receive(:fetch).with("release_highlight:items:page-1:#{Gitlab.revision}", { expires_in: described_class::CACHE_DURATION }).and_call_original
- expect(Rails.cache).to receive(:fetch).with("release_highlight:file_paths:#{Gitlab.revision}", { expires_in: described_class::CACHE_DURATION }).and_call_original
+ expect(Rails.cache).to receive(:fetch).with("release_highlight:all_tiers:items:page-1:#{Gitlab.revision}", { expires_in: described_class::CACHE_DURATION }).and_call_original
+ expect(Rails.cache).to receive(:fetch).with("release_highlight:all_tiers:file_paths:#{Gitlab.revision}", { expires_in: described_class::CACHE_DURATION }).and_call_original
subject
end
@@ -101,7 +102,7 @@ RSpec.describe ReleaseHighlight, :clean_gitlab_redis_cache do
subject { ReleaseHighlight.most_recent_item_count }
it 'uses process memory cache' do
- expect(Gitlab::ProcessMemoryCache.cache_backend).to receive(:fetch).with("release_highlight:recent_item_count:#{Gitlab.revision}", expires_in: described_class::CACHE_DURATION)
+ expect(Gitlab::ProcessMemoryCache.cache_backend).to receive(:fetch).with("release_highlight:all_tiers:recent_item_count:#{Gitlab.revision}", expires_in: described_class::CACHE_DURATION)
subject
end
@@ -127,7 +128,7 @@ RSpec.describe ReleaseHighlight, :clean_gitlab_redis_cache do
subject { ReleaseHighlight.most_recent_version_digest }
it 'uses process memory cache' do
- expect(Gitlab::ProcessMemoryCache.cache_backend).to receive(:fetch).with("release_highlight:most_recent_version_digest:#{Gitlab.revision}", expires_in: described_class::CACHE_DURATION)
+ expect(Gitlab::ProcessMemoryCache.cache_backend).to receive(:fetch).with("release_highlight:all_tiers:most_recent_version_digest:#{Gitlab.revision}", expires_in: described_class::CACHE_DURATION)
subject
end
@@ -148,6 +149,33 @@ RSpec.describe ReleaseHighlight, :clean_gitlab_redis_cache do
end
end
+ describe '.load_items' do
+ context 'whats new for all tiers' do
+ before do
+ Gitlab::CurrentSettings.update!(whats_new_variant: ApplicationSetting.whats_new_variants[:all_tiers])
+ end
+
+ it 'returns all items' do
+ items = described_class.load_items(page: 2)
+
+ expect(items.count).to eq(3)
+ end
+ end
+
+ context 'whats new for current tier only' do
+ before do
+ Gitlab::CurrentSettings.update!(whats_new_variant: ApplicationSetting.whats_new_variants[:current_tier])
+ end
+
+ it 'returns items with package=Free' do
+ items = described_class.load_items(page: 2)
+
+ expect(items.count).to eq(1)
+ expect(items.first['title']).to eq("View epics on a board")
+ end
+ end
+ end
+
describe 'QueryResult' do
subject { ReleaseHighlight::QueryResult.new(items: items, next_page: 2) }
@@ -157,4 +185,12 @@ RSpec.describe ReleaseHighlight, :clean_gitlab_redis_cache do
expect(subject.map(&:to_s)).to eq(items.map(&:to_s))
end
end
+
+ describe '.current_package' do
+ subject { described_class.current_package }
+
+ it 'returns Free' do
+ expect(subject).to eq('Free')
+ end
+ end
end
diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb
index 48f5bd114a1..b61ccee512a 100644
--- a/spec/requests/api/settings_spec.rb
+++ b/spec/requests/api/settings_spec.rb
@@ -45,6 +45,7 @@ RSpec.describe API::Settings, 'Settings', :do_not_mock_admin_mode_setting do
expect(json_response['require_admin_approval_after_user_signup']).to eq(true)
expect(json_response['personal_access_token_prefix']).to be_nil
expect(json_response['admin_mode']).to be(false)
+ expect(json_response['whats_new_variant']).to eq('all_tiers')
end
end
@@ -485,5 +486,32 @@ RSpec.describe API::Settings, 'Settings', :do_not_mock_admin_mode_setting do
end
end
end
+
+ context 'whats_new_variant setting' do
+ before do
+ Gitlab::CurrentSettings.current_application_settings.whats_new_variant_disabled!
+ end
+
+ it 'updates setting' do
+ new_value = 'all_tiers'
+ put api("/application/settings", admin),
+ params: {
+ whats_new_variant: new_value
+ }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['whats_new_variant']).to eq(new_value)
+ end
+
+ it 'fails to update setting with invalid value' do
+ put api("/application/settings", admin),
+ params: {
+ whats_new_variant: 'invalid_value'
+ }
+
+ expect(response).to have_gitlab_http_status(:bad_request)
+ expect(json_response['error']).to eq('whats_new_variant does not have a valid value')
+ end
+ end
end
end
diff --git a/spec/requests/whats_new_controller_spec.rb b/spec/requests/whats_new_controller_spec.rb
index ffb31bdf9bb..d4976a2bba3 100644
--- a/spec/requests/whats_new_controller_spec.rb
+++ b/spec/requests/whats_new_controller_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe WhatsNewController, :clean_gitlab_redis_cache do
ReleaseHighlight.instance_variable_set(:@file_paths, nil)
end
- describe 'whats_new_path' do
+ describe 'GET #index' do
let(:item) { double(:item) }
let(:highlights) { double(:highlight, items: [item], map: [item].map, next_page: 2) }
@@ -35,5 +35,17 @@ RSpec.describe WhatsNewController, :clean_gitlab_redis_cache do
expect(response).to have_gitlab_http_status(:not_found)
end
end
+
+ context 'with whats_new_variant = disabled' do
+ before do
+ Gitlab::CurrentSettings.current_application_settings.whats_new_variant_disabled!
+ end
+
+ it 'returns a 404' do
+ get whats_new_path, xhr: true
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
end
end
diff --git a/spec/support/shared_examples/features/variable_list_shared_examples.rb b/spec/support/shared_examples/features/variable_list_shared_examples.rb
index 2fd88b610e9..4b94411f009 100644
--- a/spec/support/shared_examples/features/variable_list_shared_examples.rb
+++ b/spec/support/shared_examples/features/variable_list_shared_examples.rb
@@ -8,7 +8,7 @@ RSpec.shared_examples 'variable list' do
end
it 'adds a new CI variable' do
- click_button('Add Variable')
+ click_button('Add variable')
fill_variable('key', 'key_value') do
click_button('Add variable')
@@ -22,7 +22,7 @@ RSpec.shared_examples 'variable list' do
end
it 'adds a new protected variable' do
- click_button('Add Variable')
+ click_button('Add variable')
fill_variable('key', 'key_value') do
click_button('Add variable')
@@ -37,7 +37,7 @@ RSpec.shared_examples 'variable list' do
end
it 'defaults to unmasked' do
- click_button('Add Variable')
+ click_button('Add variable')
fill_variable('key', 'key_value') do
click_button('Add variable')
@@ -149,7 +149,7 @@ RSpec.shared_examples 'variable list' do
end
it 'shows a validation error box about duplicate keys' do
- click_button('Add Variable')
+ click_button('Add variable')
fill_variable('key', 'key_value') do
click_button('Add variable')
@@ -157,7 +157,7 @@ RSpec.shared_examples 'variable list' do
wait_for_requests
- click_button('Add Variable')
+ click_button('Add variable')
fill_variable('key', 'key_value') do
click_button('Add variable')
@@ -170,7 +170,7 @@ RSpec.shared_examples 'variable list' do
end
it 'prevents a variable to be added if no values are provided when a variable is set to masked' do
- click_button('Add Variable')
+ click_button('Add variable')
page.within('#add-ci-variable') do
find('[data-qa-selector="ci_variable_key_field"] input').set('empty_mask_key')
@@ -182,7 +182,7 @@ RSpec.shared_examples 'variable list' do
end
it 'shows validation error box about unmaskable values' do
- click_button('Add Variable')
+ click_button('Add variable')
fill_variable('empty_mask_key', '???', protected: true, masked: true) do
expect(page).to have_content('This variable can not be masked')
@@ -192,7 +192,7 @@ RSpec.shared_examples 'variable list' do
it 'handles multiple edits and a deletion' do
# Create two variables
- click_button('Add Variable')
+ click_button('Add variable')
fill_variable('akey', 'akeyvalue') do
click_button('Add variable')
@@ -200,7 +200,7 @@ RSpec.shared_examples 'variable list' do
wait_for_requests
- click_button('Add Variable')
+ click_button('Add variable')
fill_variable('zkey', 'zkeyvalue') do
click_button('Add variable')
@@ -224,7 +224,7 @@ RSpec.shared_examples 'variable list' do
wait_for_requests
# Add another variable
- click_button('Add Variable')
+ click_button('Add variable')
fill_variable('ckey', 'ckeyvalue') do
click_button('Add variable')
@@ -249,7 +249,7 @@ RSpec.shared_examples 'variable list' do
end
it 'defaults to protected' do
- click_button('Add Variable')
+ click_button('Add variable')
page.within('#add-ci-variable') do
expect(find('[data-testid="ci-variable-protected-checkbox"]')).to be_checked
@@ -269,7 +269,7 @@ RSpec.shared_examples 'variable list' do
end
it 'defaults to unprotected' do
- click_button('Add Variable')
+ click_button('Add variable')
page.within('#add-ci-variable') do
expect(find('[data-testid="ci-variable-protected-checkbox"]')).not_to be_checked