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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-10-02 15:10:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-10-02 15:10:14 +0300
commit265dc26fedd34371e11c06fa7f8bcdbc273f50b5 (patch)
tree1fc74f76b210bfdfbb7f2070bf317450c2594e69
parent946ac9fa817327533b51b37037cefea2fd6ba3cc (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--app/models/namespace.rb20
-rw-r--r--doc/administration/geo/replication/datatypes.md10
-rw-r--r--spec/models/merge_request_spec.rb11
-rw-r--r--spec/models/namespace_spec.rb76
4 files changed, 90 insertions, 27 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 3ffd377251c..f7a5b976716 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -63,17 +63,27 @@ class Namespace < ApplicationRecord
length: { maximum: 255 }
validates :description, length: { maximum: 255 }
+
validates :path,
presence: true,
- length: { maximum: URL_MAX_LENGTH },
- namespace_path: true
+ length: { maximum: URL_MAX_LENGTH }
+
+ validates :path, namespace_path: true, if: ->(n) { !n.project_namespace? }
+ # Project path validator is used for project namespaces for now to assure
+ # compatibility with project paths
+ # Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/341764
+ validates :path, project_path: true, if: ->(n) { n.project_namespace? }
# Introduce minimal path length of 2 characters.
# Allow change of other attributes without forcing users to
# rename their user or group. At the same time prevent changing
# the path without complying with new 2 chars requirement.
# Issue https://gitlab.com/gitlab-org/gitlab/-/issues/225214
- validates :path, length: { minimum: 2 }, if: :path_changed?
+ #
+ # For ProjectNamespace we don't check minimal path length to keep
+ # compatibility with existing project restrictions.
+ # Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/341764
+ validates :path, length: { minimum: 2 }, if: :enforce_minimum_path_length?
validates :max_artifacts_size, numericality: { only_integer: true, greater_than: 0, allow_nil: true }
@@ -575,6 +585,10 @@ class Namespace < ApplicationRecord
project.track_project_repository
end
end
+
+ def enforce_minimum_path_length?
+ path_changed? && !project_namespace?
+ end
end
Namespace.prepend_mod_with('Namespace')
diff --git a/doc/administration/geo/replication/datatypes.md b/doc/administration/geo/replication/datatypes.md
index 3f38436429a..e8e87f92481 100644
--- a/doc/administration/geo/replication/datatypes.md
+++ b/doc/administration/geo/replication/datatypes.md
@@ -198,12 +198,12 @@ successfully, you must replicate their data using some other means.
|[Package Registry](../../../user/packages/package_registry/index.md) | **Yes** (13.2) | [**Yes**](#limitation-of-verification-for-files-in-object-storage) (13.10) | Via Object Storage provider if supported. Native Geo support (Beta). | Behind feature flag `geo_package_file_replication`, enabled by default. |
|[Versioned Terraform State](../../terraform_state.md) | **Yes** (13.5) | [**Yes**](#limitation-of-verification-for-files-in-object-storage) (13.12) | Via Object Storage provider if supported. Native Geo support (Beta). | Replication is behind the feature flag `geo_terraform_state_version_replication`, enabled by default. Verification was behind the feature flag `geo_terraform_state_version_verification`, which was removed in 14.0|
|[External merge request diffs](../../merge_request_diffs.md) | **Yes** (13.5) | No | Via Object Storage provider if supported. Native Geo support (Beta). | Replication is behind the feature flag `geo_merge_request_diff_replication`, enabled by default. Verification is under development, behind the feature flag `geo_merge_request_diff_verification`, introduced in 14.0.|
-|[Versioned snippets](../../../user/snippets.md#versioned-snippets) | [**Yes** (13.7)](https://gitlab.com/groups/gitlab-org/-/epics/2809) | [**Yes** (14.2)](https://gitlab.com/groups/gitlab-org/-/epics/2810) | No | Verification was implemented behind the feature flag `geo_snippet_repository_verification` in 13.11, and the feature flag was removed in 14.2. |
-|[Server-side Git hooks](../../server_hooks.md) | [No](https://gitlab.com/groups/gitlab-org/-/epics/1867) | No | No | |
-|[Elasticsearch integration](../../../integration/elasticsearch.md) | [No](https://gitlab.com/gitlab-org/gitlab/-/issues/1186) | No | No | |
+|[Versioned snippets](../../../user/snippets.md#versioned-snippets) | [**Yes** (13.7)](https://gitlab.com/groups/gitlab-org/-/epics/2809) | [**Yes** (14.2)](https://gitlab.com/groups/gitlab-org/-/epics/2810) | No | Verification was implemented behind the feature flag `geo_snippet_repository_verification` in 13.11, and the feature flag was removed in 14.2. |
|[GitLab Pages](../../pages/index.md) | [**Yes** (14.3)](https://gitlab.com/groups/gitlab-org/-/epics/589) | No | Via Object Storage provider if supported. Native Geo support (Beta). | Behind feature flag `geo_pages_deployment_replication`, enabled by default. |
-|[Dependency proxy images](../../../user/packages/dependency_proxy/index.md) | [No](https://gitlab.com/gitlab-org/gitlab/-/issues/259694) | No | No | Blocked on [Geo: Secondary Mimicry](https://gitlab.com/groups/gitlab-org/-/epics/1528). Replication of this cache is not needed for Disaster Recovery purposes because it can be recreated from external sources. |
-|[Vulnerability Export](../../../user/application_security/vulnerability_report/#export-vulnerability-details) | [Not planned](https://gitlab.com/groups/gitlab-org/-/epics/3111) | No | | Not planned because they are ephemeral and sensitive. They can be regenerated on demand. |
+|[Server-side Git hooks](../../server_hooks.md) | [Not planned](https://gitlab.com/groups/gitlab-org/-/epics/1867) | No | No | Not planned because of current implementation complexity, low customer interest, and availability of alternatives to hooks. |
+|[Elasticsearch integration](../../../integration/elasticsearch.md) | [Not planned](https://gitlab.com/gitlab-org/gitlab/-/issues/1186) | No | No | Not planned because further product discovery is required and Elasticsearch (ES) clusters can be rebuilt. Secondaries currently use the same ES cluster as the primary. |
+|[Dependency proxy images](../../../user/packages/dependency_proxy/index.md) | [Not planned](https://gitlab.com/gitlab-org/gitlab/-/issues/259694) | No | No | Blocked by [Geo: Secondary Mimicry](https://gitlab.com/groups/gitlab-org/-/epics/1528). Replication of this cache is not needed for disaster recovery purposes because it can be recreated from external sources. |
+|[Vulnerability Export](../../../user/application_security/vulnerability_report/#export-vulnerability-details) | [Not planned](https://gitlab.com/groups/gitlab-org/-/epics/3111) | No | No | Not planned because they are ephemeral and sensitive information. They can be regenerated on demand. |
#### Limitation of verification for files in Object Storage
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index 06ca88644b7..1eb54ee73f9 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -1357,6 +1357,17 @@ RSpec.describe MergeRequest, factory_default: :keep do
end
end
+ [
+ "WIP ", "(WIP)",
+ "draft", "Draft"
+ ].each do |draft_prefix|
+ it "doesn't detect '#{draft_prefix}' at the start of the title as a draft" do
+ subject.title = "#{draft_prefix}#{subject.title}"
+
+ expect(subject.work_in_progress?).to eq false
+ end
+ end
+
it "detects merge request title just saying 'wip'" do
subject.title = "wip"
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index bfe06c44839..bc117de75cc 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -133,39 +133,77 @@ RSpec.describe Namespace do
end
context 'top-level group' do
- let(:group) { build(:group, path: 'tree') }
+ let(:group) { build(:namespace, path: 'tree') }
it { expect(group).to be_valid }
end
end
- describe '1 char path length' do
- it 'does not allow to create one' do
- namespace = build(:namespace, path: 'j')
+ describe 'path validator' do
+ using RSpec::Parameterized::TableSyntax
- expect(namespace).not_to be_valid
- expect(namespace.errors[:path].first).to eq('is too short (minimum is 2 characters)')
+ let_it_be(:parent) { create(:namespace) }
+
+ # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
+ where(:namespace_type, :path, :valid) do
+ ref(:project_sti_name) | 'j' | true
+ ref(:project_sti_name) | 'path.' | true
+ ref(:project_sti_name) | 'blob' | false
+ ref(:group_sti_name) | 'j' | false
+ ref(:group_sti_name) | 'path.' | false
+ ref(:group_sti_name) | 'blob' | true
+ ref(:user_sti_name) | 'j' | false
+ ref(:user_sti_name) | 'path.' | false
+ ref(:user_sti_name) | 'blob' | true
end
+ # rubocop:enable Lint/BinaryOperatorWithIdenticalOperands
- it 'does not allow to update one' do
- namespace = create(:namespace)
- namespace.update(path: 'j')
+ with_them do
+ it 'validates namespace path' do
+ parent_namespace = parent if namespace_type == Namespaces::ProjectNamespace.sti_name
+ namespace = build(:namespace, type: namespace_type, parent: parent_namespace, path: path)
- expect(namespace).not_to be_valid
- expect(namespace.errors[:path].first).to eq('is too short (minimum is 2 characters)')
+ expect(namespace.valid?).to be(valid)
+ end
end
+ end
- it 'allows updating other attributes for existing record' do
- namespace = build(:namespace, path: 'j', owner: create(:user))
- namespace.save(validate: false)
- namespace.reload
+ describe '1 char path length' do
+ context 'with user namespace' do
+ let(:namespace) { build(:namespace) }
- expect(namespace.path).to eq('j')
+ it 'does not allow to update path to single char' do
+ namespace.save!
- namespace.update(name: 'something new')
+ namespace.path = 'j'
- expect(namespace).to be_valid
- expect(namespace.name).to eq('something new')
+ expect(namespace).not_to be_valid
+ expect(namespace.errors[:path].first).to eq('is too short (minimum is 2 characters)')
+ end
+
+ it 'allows updating other attributes for existing record' do
+ namespace.save!
+ namespace.update_attribute(:path, 'j')
+ namespace.reload
+
+ expect(namespace.path).to eq('j')
+
+ namespace.update(name: 'something new')
+
+ expect(namespace).to be_valid
+ expect(namespace.name).to eq('something new')
+ end
+ end
+
+ context 'with project namespace' do
+ let(:namespace) { build(:project_namespace) }
+
+ it 'allows to update path to single char' do
+ namespace = create(:project_namespace)
+ namespace.update(path: 'j')
+
+ expect(namespace).to be_valid
+ end
end
end
end