summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/import_export/json/legacy_reader/hash_spec.rb
blob: e793dc7339dcdecdedfc84e83765d559af2c87dd (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
# frozen_string_literal: true

require 'spec_helper'
require_relative 'shared_example.rb'

describe Gitlab::ImportExport::JSON::LegacyReader::Hash do
  it_behaves_like 'import/export json legacy reader' do
    let(:path) { 'spec/fixtures/lib/gitlab/import_export/light/project.json' }

    # the hash is modified by the `LegacyReader`
    # we need to deep-dup it
    let(:json_data) { Gitlab::Json.parse(File.read(path)) }
    let(:data) { Gitlab::Json.parse(File.read(path)) }
  end

  describe '#exist?' do
    let(:legacy_reader) do
      described_class.new(tree_hash, relation_names: [])
    end

    subject { legacy_reader.exist? }

    context 'tree_hash is nil' do
      let(:tree_hash) { nil }

      it { is_expected.to be_falsey }
    end

    context 'tree_hash presents' do
      let(:tree_hash) { { "issues": [] } }

      it { is_expected.to be_truthy }
    end
  end
end