debian-mirror-gitlab/spec/lib/gitlab/slug/path_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
1,017 B
Ruby
Raw Normal View History

2023-04-23 21:23:45 +05:30
# frozen_string_literal: true
require 'fast_spec_helper'
2023-05-27 22:25:52 +05:30
RSpec.describe Gitlab::Slug::Path, feature_category: :shared do
2023-04-23 21:23:45 +05:30
describe '#generate' do
{
'name': 'name',
'james.atom@bond.com': 'james',
'--foobar--': 'foobar--',
'--foo_bar--': 'foo_bar--',
'--foo$^&_bar--': 'foo_bar--',
'john@doe.com': 'john',
'-john+gitlab-ETC%.git@gmail.com': 'johngitlab-ETC',
'this.is.git.atom.': 'this.is',
'#$%^.': 'blank',
'---.git#$.atom%@atom^.': 'blank', # use default when all characters are filtered out
'--gitlab--hey.git#$.atom%@atom^.': 'gitlab--hey'
}.each do |input, output|
it "yields a slug #{output} when given #{input}" do
slug = described_class.new(input).generate
expect(slug).to match(/\A#{output}\z/)
end
end
end
describe '#to_s' do
it 'presents with a cleaned slug' do
expect(described_class.new('---show-me-what-you.got.git').to_s).to match(/\Ashow-me-what-you.got\z/)
end
end
end