Welcome to mirror list, hosted at ThFree Co, Russian Federation.

path_spec.rb « slug « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bbc2a05713ded9d37cd57b252dc1617c2289fd25 (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
# frozen_string_literal: true

require 'fast_spec_helper'

RSpec.describe Gitlab::Slug::Path, feature_category: :shared do
  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