summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/database/rename_reserved_paths_migration/v1_spec.rb
blob: f8cc1eb91ec9945097e9f1e77ba713ea99a8c495 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'spec_helper'

shared_examples 'renames child namespaces' do |type|
  it 'renames namespaces' do
    rename_namespaces = double
    expect(described_class::RenameNamespaces).
      to receive(:new).with(['first-path', 'second-path'], subject).
           and_return(rename_namespaces)
    expect(rename_namespaces).to receive(:rename_namespaces).
                                   with(type: :child)

    subject.rename_wildcard_paths(['first-path', 'second-path'])
  end
end

describe Gitlab::Database::RenameReservedPathsMigration::V1 do
  let(:subject) { FakeRenameReservedPathMigrationV1.new }

  before do
    allow(subject).to receive(:say)
  end

  describe '#rename_child_paths' do
    it_behaves_like 'renames child namespaces'
  end

  describe '#rename_wildcard_paths' do
    it_behaves_like 'renames child namespaces'

    it 'should rename projects' do
      rename_projects = double
      expect(described_class::RenameProjects).
        to receive(:new).with(['the-path'], subject).
             and_return(rename_projects)

      expect(rename_projects).to receive(:rename_projects)

      subject.rename_wildcard_paths(['the-path'])
    end
  end

  describe '#rename_root_paths' do
    it 'should rename namespaces' do
      rename_namespaces = double
      expect(described_class::RenameNamespaces).
        to receive(:new).with(['the-path'], subject).
             and_return(rename_namespaces)
      expect(rename_namespaces).to receive(:rename_namespaces).
                           with(type: :top_level)

      subject.rename_root_paths('the-path')
    end
  end
end