summaryrefslogtreecommitdiff
path: root/spec/lib/backup/repository_backup_error_spec.rb
blob: 44c75c1cf77d037b071033e5878387e229c976ab (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Backup::RepositoryBackupError do
  let_it_be(:snippet) { create(:snippet, content: 'foo', file_name: 'foo') }
  let_it_be(:project) { create(:project, :repository) }
  let_it_be(:wiki) { ProjectWiki.new(project, nil ) }

  let(:backup_repos_path) { '/tmp/backup/repositories' }

  shared_examples 'includes backup path' do
    it { is_expected.to respond_to :container }
    it { is_expected.to respond_to :backup_repos_path }

    it 'expects exception message to include repo backup path location' do
      expect(subject.message).to include("#{subject.backup_repos_path}")
    end

    it 'expects exception message to include container being back-up' do
      expect(subject.message).to include("#{subject.container.disk_path}")
    end
  end

  context 'with snippet repository' do
    subject { described_class.new(snippet, backup_repos_path) }

    it_behaves_like 'includes backup path'
  end

  context 'with project repository' do
    subject { described_class.new(project, backup_repos_path) }

    it_behaves_like 'includes backup path'
  end

  context 'with wiki repository' do
    subject { described_class.new(wiki, backup_repos_path) }

    it_behaves_like 'includes backup path'
  end
end