diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 82e59e0104b4821382226f55dea412a771867690..cb16e0e9d81048416c39357f9e268dbc0e56bad6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -798,10 +798,6 @@ Rails/SaveBang: - 'ee/spec/models/license_spec.rb' - 'ee/spec/models/merge_request_spec.rb' - 'ee/spec/models/merge_train_spec.rb' - - 'ee/spec/models/operations/feature_flag_scope_spec.rb' - - 'ee/spec/models/operations/feature_flag_spec.rb' - - 'ee/spec/models/operations/feature_flags/strategy_spec.rb' - - 'ee/spec/models/operations/feature_flags/user_list_spec.rb' - 'spec/models/packages/package_spec.rb' - 'ee/spec/models/project_ci_cd_setting_spec.rb' - 'ee/spec/models/project_services/github_service_spec.rb' @@ -1188,6 +1184,10 @@ Rails/SaveBang: - 'spec/models/namespace_spec.rb' - 'spec/models/note_spec.rb' - 'spec/models/notification_setting_spec.rb' + - 'spec/models/operations/feature_flag_scope_spec.rb' + - 'spec/models/operations/feature_flag_spec.rb' + - 'spec/models/operations/feature_flags/strategy_spec.rb' + - 'spec/models/operations/feature_flags/user_list_spec.rb' - 'spec/models/pages_domain_spec.rb' - 'spec/models/project_auto_devops_spec.rb' - 'spec/models/project_feature_spec.rb' diff --git a/ee/app/models/operations/feature_flag.rb b/app/models/operations/feature_flag.rb similarity index 100% rename from ee/app/models/operations/feature_flag.rb rename to app/models/operations/feature_flag.rb diff --git a/ee/app/models/operations/feature_flag_scope.rb b/app/models/operations/feature_flag_scope.rb similarity index 100% rename from ee/app/models/operations/feature_flag_scope.rb rename to app/models/operations/feature_flag_scope.rb diff --git a/ee/app/models/operations/feature_flags/scope.rb b/app/models/operations/feature_flags/scope.rb similarity index 100% rename from ee/app/models/operations/feature_flags/scope.rb rename to app/models/operations/feature_flags/scope.rb diff --git a/ee/app/models/operations/feature_flags/strategy.rb b/app/models/operations/feature_flags/strategy.rb similarity index 100% rename from ee/app/models/operations/feature_flags/strategy.rb rename to app/models/operations/feature_flags/strategy.rb diff --git a/ee/app/models/operations/feature_flags/strategy_user_list.rb b/app/models/operations/feature_flags/strategy_user_list.rb similarity index 100% rename from ee/app/models/operations/feature_flags/strategy_user_list.rb rename to app/models/operations/feature_flags/strategy_user_list.rb diff --git a/ee/app/models/operations/feature_flags/user_list.rb b/app/models/operations/feature_flags/user_list.rb similarity index 100% rename from ee/app/models/operations/feature_flags/user_list.rb rename to app/models/operations/feature_flags/user_list.rb diff --git a/ee/app/models/operations/feature_flags_client.rb b/app/models/operations/feature_flags_client.rb similarity index 100% rename from ee/app/models/operations/feature_flags_client.rb rename to app/models/operations/feature_flags_client.rb diff --git a/app/models/project.rb b/app/models/project.rb index 89dda18378820aead81b8d673e6290ed250e0184..a5317d14dd8091c32819943ad224a51bee515f23 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -344,6 +344,10 @@ class Project < ApplicationRecord # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/228637 has_many :product_analytics_events, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent + has_many :operations_feature_flags, class_name: 'Operations::FeatureFlag' + has_one :operations_feature_flags_client, class_name: 'Operations::FeatureFlagsClient' + has_many :operations_feature_flags_user_lists, class_name: 'Operations::FeatureFlags::UserList' + accepts_nested_attributes_for :variables, allow_destroy: true accepts_nested_attributes_for :project_feature, update_only: true accepts_nested_attributes_for :project_setting, update_only: true diff --git a/ee/app/validators/feature_flag_strategies_validator.rb b/app/validators/feature_flag_strategies_validator.rb similarity index 100% rename from ee/app/validators/feature_flag_strategies_validator.rb rename to app/validators/feature_flag_strategies_validator.rb diff --git a/ee/app/validators/feature_flag_user_xids_validator.rb b/app/validators/feature_flag_user_xids_validator.rb similarity index 100% rename from ee/app/validators/feature_flag_user_xids_validator.rb rename to app/validators/feature_flag_user_xids_validator.rb diff --git a/config/routes/project.rb b/config/routes/project.rb index 8c9b1f7f5cd4278758a03a6caede255e2d031346..4ba1f14222e7025df888766c1406aeca9f3bf5f9 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -367,6 +367,14 @@ post :mark_as_spam end end + + resources :feature_flags, param: :iid do + resources :feature_flag_issues, only: [:index, :create, :destroy], as: 'issues', path: 'issues' + end + resource :feature_flags_client, only: [] do + post :reset_token + end + resources :feature_flags_user_lists, param: :iid, only: [:new, :edit, :show] end # End of the /-/ scope. diff --git a/ee/app/models/ee/project.rb b/ee/app/models/ee/project.rb index c9b58447c9683fc4ac11d237f3581c7548d12e44..349e0147ea64a2fe2265dfc4c197ac8efa572158 100644 --- a/ee/app/models/ee/project.rb +++ b/ee/app/models/ee/project.rb @@ -81,10 +81,6 @@ def lock_for_confirmation!(id) accepts_nested_attributes_for :software_license_policies, allow_destroy: true has_many :merge_trains, foreign_key: 'target_project_id', inverse_of: :target_project - has_many :operations_feature_flags, class_name: 'Operations::FeatureFlag' - has_one :operations_feature_flags_client, class_name: 'Operations::FeatureFlagsClient' - has_many :operations_feature_flags_user_lists, class_name: 'Operations::FeatureFlags::UserList' - has_many :project_aliases has_many :upstream_project_subscriptions, class_name: 'Ci::Subscriptions::Project', foreign_key: :downstream_project_id, inverse_of: :downstream_project diff --git a/ee/config/routes/project.rb b/ee/config/routes/project.rb index 0346c302d7044bfa77dc096c8b214ca2b4e83d0a..374f346ee4ca1bd71a3b13140b6b948d96255d10 100644 --- a/ee/config/routes/project.rb +++ b/ee/config/routes/project.rb @@ -19,14 +19,6 @@ resources :test_cases, only: [:index] end - resources :feature_flags, param: :iid do - resources :feature_flag_issues, only: [:index, :create, :destroy], as: 'issues', path: 'issues' - end - resource :feature_flags_client, only: [] do - post :reset_token - end - resources :feature_flags_user_lists, param: :iid, only: [:new, :edit, :show] - resources :autocomplete_sources, only: [] do collection do get 'epics' diff --git a/ee/lib/ee/gitlab/regex.rb b/ee/lib/ee/gitlab/regex.rb deleted file mode 100644 index 9b350c005b119c0776a47ac19679e59beeac6d18..0000000000000000000000000000000000000000 --- a/ee/lib/ee/gitlab/regex.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -module EE - module Gitlab - module Regex - extend ActiveSupport::Concern - - class_methods do - def feature_flag_regex - /\A[a-z]([-_a-z0-9]*[a-z0-9])?\z/ - end - - def feature_flag_regex_message - "can contain only lowercase letters, digits, '_' and '-'. " \ - "Must start with a letter, and cannot end with '-' or '_'" - end - end - end - end -end diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb index 06e8a9ec64982e6a366de846e2ed053906a9ce7d..8e23ac6aca5e0e94992cc9fedfb973a5053c8d15 100644 --- a/lib/gitlab/regex.rb +++ b/lib/gitlab/regex.rb @@ -292,7 +292,14 @@ def issue def base64_regex @base64_regex ||= /(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?/.freeze end + + def feature_flag_regex + /\A[a-z]([-_a-z0-9]*[a-z0-9])?\z/ + end + + def feature_flag_regex_message + "can contain only lowercase letters, digits, '_' and '-'. " \ + "Must start with a letter, and cannot end with '-' or '_'" + end end end - -Gitlab::Regex.prepend_if_ee('EE::Gitlab::Regex') diff --git a/ee/spec/factories/operations/feature_flag_scopes.rb b/spec/factories/operations/feature_flag_scopes.rb similarity index 100% rename from ee/spec/factories/operations/feature_flag_scopes.rb rename to spec/factories/operations/feature_flag_scopes.rb diff --git a/ee/spec/factories/operations/feature_flags.rb b/spec/factories/operations/feature_flags.rb similarity index 100% rename from ee/spec/factories/operations/feature_flags.rb rename to spec/factories/operations/feature_flags.rb diff --git a/ee/spec/factories/operations/feature_flags/scope.rb b/spec/factories/operations/feature_flags/scope.rb similarity index 100% rename from ee/spec/factories/operations/feature_flags/scope.rb rename to spec/factories/operations/feature_flags/scope.rb diff --git a/ee/spec/factories/operations/feature_flags/strategy.rb b/spec/factories/operations/feature_flags/strategy.rb similarity index 100% rename from ee/spec/factories/operations/feature_flags/strategy.rb rename to spec/factories/operations/feature_flags/strategy.rb diff --git a/ee/spec/factories/operations/feature_flags/user_list.rb b/spec/factories/operations/feature_flags/user_list.rb similarity index 100% rename from ee/spec/factories/operations/feature_flags/user_list.rb rename to spec/factories/operations/feature_flags/user_list.rb diff --git a/ee/spec/factories/operations/feature_flags_clients.rb b/spec/factories/operations/feature_flags_clients.rb similarity index 100% rename from ee/spec/factories/operations/feature_flags_clients.rb rename to spec/factories/operations/feature_flags_clients.rb diff --git a/ee/spec/models/operations/feature_flag_scope_spec.rb b/spec/models/operations/feature_flag_scope_spec.rb similarity index 100% rename from ee/spec/models/operations/feature_flag_scope_spec.rb rename to spec/models/operations/feature_flag_scope_spec.rb diff --git a/ee/spec/models/operations/feature_flag_spec.rb b/spec/models/operations/feature_flag_spec.rb similarity index 100% rename from ee/spec/models/operations/feature_flag_spec.rb rename to spec/models/operations/feature_flag_spec.rb diff --git a/ee/spec/models/operations/feature_flags/strategy_spec.rb b/spec/models/operations/feature_flags/strategy_spec.rb similarity index 100% rename from ee/spec/models/operations/feature_flags/strategy_spec.rb rename to spec/models/operations/feature_flags/strategy_spec.rb diff --git a/ee/spec/models/operations/feature_flags/user_list_spec.rb b/spec/models/operations/feature_flags/user_list_spec.rb similarity index 100% rename from ee/spec/models/operations/feature_flags/user_list_spec.rb rename to spec/models/operations/feature_flags/user_list_spec.rb diff --git a/ee/spec/models/operations/feature_flags_client_spec.rb b/spec/models/operations/feature_flags_client_spec.rb similarity index 100% rename from ee/spec/models/operations/feature_flags_client_spec.rb rename to spec/models/operations/feature_flags_client_spec.rb diff --git a/ee/spec/support/helpers/feature_flag_helpers.rb b/spec/support/helpers/feature_flag_helpers.rb similarity index 100% rename from ee/spec/support/helpers/feature_flag_helpers.rb rename to spec/support/helpers/feature_flag_helpers.rb