From c03e41278a15b5ab76b52cc9fe27f5f060a74bc3 Mon Sep 17 00:00:00 2001 From: Ana Schwendler <schwendler@gmail.com> Date: Fri, 7 Jul 2023 00:48:05 +0000 Subject: [PATCH] Unify true-false validation specs II After making sure our changes to one file were correct, I moved forward with the remaining files with that syntax. Next steps: document this preference in the documentation Changelog: other --- ee/spec/models/application_setting_spec.rb | 12 ++++-------- ee/spec/models/namespace_setting_spec.rb | 6 ++---- ee/spec/models/vulnerabilities/read_spec.rb | 6 ++---- spec/models/container_expiration_policy_spec.rb | 3 +-- .../dependency_proxy/image_ttl_group_policy_spec.rb | 3 +-- spec/models/integrations/apple_app_store_spec.rb | 3 +-- spec/models/namespace/package_setting_spec.rb | 6 ++---- spec/models/project_setting_spec.rb | 3 +-- spec/models/user_preference_spec.rb | 3 +-- 9 files changed, 15 insertions(+), 30 deletions(-) diff --git a/ee/spec/models/application_setting_spec.rb b/ee/spec/models/application_setting_spec.rb index 379ae957206c6..fd2a22db34bf1 100644 --- a/ee/spec/models/application_setting_spec.rb +++ b/ee/spec/models/application_setting_spec.rb @@ -92,8 +92,7 @@ it { is_expected.to allow_value('a' * 255).for(:elasticsearch_username) } it { is_expected.not_to allow_value('a' * 256).for(:elasticsearch_username) } - it { is_expected.to allow_value(true).for(:security_policy_global_group_approvers_enabled) } - it { is_expected.to allow_value(false).for(:security_policy_global_group_approvers_enabled) } + it { is_expected.to allow_value(true, false).for(:security_policy_global_group_approvers_enabled) } it { is_expected.not_to allow_value(nil).for(:security_policy_global_group_approvers_enabled) } end @@ -151,13 +150,11 @@ it { is_expected.to validate_numericality_of(:dashboard_limit).only_integer.is_greater_than_or_equal_to(0) } it { is_expected.to validate_numericality_of(:dashboard_notification_limit).only_integer.is_greater_than_or_equal_to(0) } it { is_expected.to validate_numericality_of(:dashboard_enforcement_limit).only_integer.is_greater_than_or_equal_to(0) } - it { is_expected.to allow_value(true).for(:dashboard_limit_enabled) } - it { is_expected.to allow_value(false).for(:dashboard_limit_enabled) } + it { is_expected.to allow_value(true, false).for(:dashboard_limit_enabled) } it { is_expected.not_to allow_value(nil).for(:dashboard_limit_enabled) } end - it { is_expected.to allow_value(true).for(:allow_account_deletion) } - it { is_expected.to allow_value(false).for(:allow_account_deletion) } + it { is_expected.to allow_value(true, false).for(:allow_account_deletion) } it { is_expected.not_to allow_value(nil).for(:allow_account_deletion) } describe 'when additional email text is enabled', feature_category: :user_profile do @@ -1238,8 +1235,7 @@ def expect_is_es_licensed expect(setting.lock_delayed_project_removal).to be false end - it { is_expected.to allow_value(false).for(:delayed_project_removal) } - it { is_expected.to allow_value(true).for(:delayed_project_removal) } + it { is_expected.to allow_value(true, false).for(:delayed_project_removal) } end end diff --git a/ee/spec/models/namespace_setting_spec.rb b/ee/spec/models/namespace_setting_spec.rb index a28f03f7bdee6..d1b00a035ef42 100644 --- a/ee/spec/models/namespace_setting_spec.rb +++ b/ee/spec/models/namespace_setting_spec.rb @@ -53,8 +53,7 @@ allow(subject).to receive(:ai_settings_allowed?).and_return(true) end - it { is_expected.to allow_value(false).for(attr) } - it { is_expected.to allow_value(true).for(attr) } + it { is_expected.to allow_value(true, false).for(attr) } it { is_expected.not_to allow_value(nil).for(attr) } context 'when AI settings are not allowed' do @@ -80,8 +79,7 @@ allow(subject).to receive(:ai_assist_ui_enabled?).and_return(true) end - it { is_expected.to allow_value(false).for(:third_party_ai_features_enabled) } - it { is_expected.to allow_value(true).for(:third_party_ai_features_enabled) } + it { is_expected.to allow_value(true, false).for(:third_party_ai_features_enabled) } it { is_expected.not_to allow_value(nil).for(:third_party_ai_features_enabled) } end end diff --git a/ee/spec/models/vulnerabilities/read_spec.rb b/ee/spec/models/vulnerabilities/read_spec.rb index e25eaca6cce5d..10a95dd1519e3 100644 --- a/ee/spec/models/vulnerabilities/read_spec.rb +++ b/ee/spec/models/vulnerabilities/read_spec.rb @@ -26,12 +26,10 @@ it { is_expected.to validate_uniqueness_of(:vulnerability_id) } it { is_expected.to validate_uniqueness_of(:uuid).case_insensitive } - it { is_expected.to allow_value(true).for(:has_issues) } - it { is_expected.to allow_value(false).for(:has_issues) } + it { is_expected.to allow_value(true, false).for(:has_issues) } it { is_expected.not_to allow_value(nil).for(:has_issues) } - it { is_expected.to allow_value(true).for(:resolved_on_default_branch) } - it { is_expected.to allow_value(false).for(:resolved_on_default_branch) } + it { is_expected.to allow_value(true, false).for(:resolved_on_default_branch) } it { is_expected.not_to allow_value(nil).for(:resolved_on_default_branch) } end diff --git a/spec/models/container_expiration_policy_spec.rb b/spec/models/container_expiration_policy_spec.rb index b88eddf19dcbf..e5f9fdd410e77 100644 --- a/spec/models/container_expiration_policy_spec.rb +++ b/spec/models/container_expiration_policy_spec.rb @@ -11,8 +11,7 @@ it { is_expected.to validate_presence_of(:project) } describe '#enabled' do - it { is_expected.to allow_value(true).for(:enabled) } - it { is_expected.to allow_value(false).for(:enabled) } + it { is_expected.to allow_value(true, false).for(:enabled) } it { is_expected.not_to allow_value(nil).for(:enabled) } end diff --git a/spec/models/dependency_proxy/image_ttl_group_policy_spec.rb b/spec/models/dependency_proxy/image_ttl_group_policy_spec.rb index 9f6358e128695..a58e8df45e4b3 100644 --- a/spec/models/dependency_proxy/image_ttl_group_policy_spec.rb +++ b/spec/models/dependency_proxy/image_ttl_group_policy_spec.rb @@ -11,8 +11,7 @@ it { is_expected.to validate_presence_of(:group) } describe '#enabled' do - it { is_expected.to allow_value(true).for(:enabled) } - it { is_expected.to allow_value(false).for(:enabled) } + it { is_expected.to allow_value(true, false).for(:enabled) } it { is_expected.not_to allow_value(nil).for(:enabled) } end diff --git a/spec/models/integrations/apple_app_store_spec.rb b/spec/models/integrations/apple_app_store_spec.rb index f3346acae0a85..9864fe38d3fca 100644 --- a/spec/models/integrations/apple_app_store_spec.rb +++ b/spec/models/integrations/apple_app_store_spec.rb @@ -13,8 +13,7 @@ it { is_expected.to validate_presence_of :app_store_key_id } it { is_expected.to validate_presence_of :app_store_private_key } it { is_expected.to validate_presence_of :app_store_private_key_file_name } - it { is_expected.to allow_value(true).for(:app_store_protected_refs) } - it { is_expected.to allow_value(false).for(:app_store_protected_refs) } + it { is_expected.to allow_value(true, false).for(:app_store_protected_refs) } it { is_expected.not_to allow_value(nil).for(:app_store_protected_refs) } it { is_expected.to allow_value('aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee').for(:app_store_issuer_id) } it { is_expected.not_to allow_value('abcde').for(:app_store_issuer_id) } diff --git a/spec/models/namespace/package_setting_spec.rb b/spec/models/namespace/package_setting_spec.rb index 72ecad42a70b4..9dfb58301b104 100644 --- a/spec/models/namespace/package_setting_spec.rb +++ b/spec/models/namespace/package_setting_spec.rb @@ -11,11 +11,9 @@ it { is_expected.to validate_presence_of(:namespace) } describe '#maven_duplicates_allowed' do - it { is_expected.to allow_value(true).for(:maven_duplicates_allowed) } - it { is_expected.to allow_value(false).for(:maven_duplicates_allowed) } + it { is_expected.to allow_value(true, false).for(:maven_duplicates_allowed) } it { is_expected.not_to allow_value(nil).for(:maven_duplicates_allowed) } - it { is_expected.to allow_value(true).for(:generic_duplicates_allowed) } - it { is_expected.to allow_value(false).for(:generic_duplicates_allowed) } + it { is_expected.to allow_value(true, false).for(:generic_duplicates_allowed) } it { is_expected.not_to allow_value(nil).for(:generic_duplicates_allowed) } end diff --git a/spec/models/project_setting_spec.rb b/spec/models/project_setting_spec.rb index 4b2760d7699c8..6928cc8ba0832 100644 --- a/spec/models/project_setting_spec.rb +++ b/spec/models/project_setting_spec.rb @@ -27,8 +27,7 @@ it { is_expected.to validate_length_of(:issue_branch_template).is_at_most(255) } it { is_expected.not_to allow_value(nil).for(:suggested_reviewers_enabled) } - it { is_expected.to allow_value(true).for(:suggested_reviewers_enabled) } - it { is_expected.to allow_value(false).for(:suggested_reviewers_enabled) } + it { is_expected.to allow_value(true, false).for(:suggested_reviewers_enabled) } it 'allows any combination of the allowed target platforms' do valid_target_platform_combinations.each do |target_platforms| diff --git a/spec/models/user_preference_spec.rb b/spec/models/user_preference_spec.rb index 17899012aaa1e..729635b5a27f1 100644 --- a/spec/models/user_preference_spec.rb +++ b/spec/models/user_preference_spec.rb @@ -49,8 +49,7 @@ end describe 'pass_user_identities_to_ci_jwt' do - it { is_expected.to allow_value(true).for(:pass_user_identities_to_ci_jwt) } - it { is_expected.to allow_value(false).for(:pass_user_identities_to_ci_jwt) } + it { is_expected.to allow_value(true, false).for(:pass_user_identities_to_ci_jwt) } it { is_expected.not_to allow_value(nil).for(:pass_user_identities_to_ci_jwt) } it { is_expected.not_to allow_value("").for(:pass_user_identities_to_ci_jwt) } end -- GitLab