diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-07 18:09:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-07 18:09:14 +0300 |
commit | 9498dc957345829f29fe0bc4e55c969783b457be (patch) | |
tree | ca19b899f1eee13ad892fe18ece040347c3a1e71 /spec/validators | |
parent | ba27dbddc7dbc42f2cc8d84e815a9ea19f87a81d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/validators')
-rw-r--r-- | spec/validators/organizations/path_validator_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/validators/organizations/path_validator_spec.rb b/spec/validators/organizations/path_validator_spec.rb new file mode 100644 index 00000000000..415c10d98df --- /dev/null +++ b/spec/validators/organizations/path_validator_spec.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Organizations::PathValidator, feature_category: :cell do + let(:validator) { described_class.new(attributes: [:path]) } + + describe '.valid_path?' do + it 'handles invalid utf8' do + expect(described_class.valid_path?(+"a\0weird\255path")).to be_falsey + end + end + + describe '#validates_each' do + it 'adds a message when the path is not in the correct format' do + organization = build(:organization) + + validator.validate_each(organization, :path, "Path with spaces, and comma's!") + + expect(organization.errors[:path]).to include(Gitlab::PathRegex.namespace_format_message) + end + + it 'adds a message when the path is reserved when creating' do + organization = build(:organization, path: 'help') + + validator.validate_each(organization, :path, 'help') + + expect(organization.errors[:path]).to include('help is a reserved name') + end + + it 'adds a message when the path is reserved when updating' do + organization = create(:organization) + organization.path = 'help' + + validator.validate_each(organization, :path, 'help') + + expect(organization.errors[:path]).to include('help is a reserved name') + end + end +end |