blob: 415c10d98dfe5cbb808185cb6993eb6c1eac457d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
|