blob: b8a6feb6c73474a0031233b9b4a3598c4d7ef128 (
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
|
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GithubImport::IssuableFinder, :clean_gitlab_redis_cache do
let(:project) { double(:project, id: 4) }
let(:issue) do
double(:issue, issuable_type: MergeRequest, iid: 1)
end
let(:finder) { described_class.new(project, issue) }
describe '#database_id' do
it 'returns nil when no cache is in place' do
expect(finder.database_id).to be_nil
end
it 'returns the ID of an issuable when the cache is in place' do
finder.cache_database_id(10)
expect(finder.database_id).to eq(10)
end
it 'raises TypeError when the object is not supported' do
finder = described_class.new(project, double(:issue))
expect { finder.database_id }.to raise_error(TypeError)
end
end
describe '#cache_database_id' do
it 'caches the ID of a database row' do
expect(Gitlab::GithubImport::Caching)
.to receive(:write)
.with('github-import/issuable-finder/4/MergeRequest/1', 10)
finder.cache_database_id(10)
end
end
end
|