gitlab-org--gitlab-foss/spec/lib/git_ref_validator_spec.rb
Matthieu Tardy 7a399b7061 Strip reference prefixes on branch creation
Signed-off-by: Matthieu Tardy <matthieu.tardy@gmail.com>
2017-01-09 13:38:44 +01:00

25 lines
1.7 KiB
Ruby

require 'spec_helper'
describe Gitlab::GitRefValidator, lib: true do
it { expect(Gitlab::GitRefValidator.validate('feature/new')).to be_truthy }
it { expect(Gitlab::GitRefValidator.validate('implement_@all')).to be_truthy }
it { expect(Gitlab::GitRefValidator.validate('my_new_feature')).to be_truthy }
it { expect(Gitlab::GitRefValidator.validate('#1')).to be_truthy }
it { expect(Gitlab::GitRefValidator.validate('feature/refs/heads/foo')).to be_truthy }
it { expect(Gitlab::GitRefValidator.validate('feature/~new/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature/^new/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature/:new/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature/?new/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature/*new/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature/[new/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature/new/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature/new.')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature\@{')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature\new')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature//new')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature new')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('refs/heads/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('refs/remotes/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('refs/heads/feature')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('refs/remotes/origin')).to be_falsey }
end