blob: 33d7a7130dd008bb26a074c82546b13b7f897c94 (
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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Banzai::ReferenceParser::AlertParser, feature_category: :team_planning do
include ReferenceParserHelpers
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
let(:alert) { create(:alert_management_alert, project: project) }
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
describe '#nodes_visible_to_user' do
context 'when the link has a data-issue attribute' do
before do
link['data-alert'] = alert.id.to_s
end
it_behaves_like "referenced feature visibility", "issues", "merge_requests" do
before do
project.add_developer(user) if enable_user?
end
end
end
end
describe '#referenced_by' do
describe 'when the link has a data-alert attribute' do
context 'using an existing alert ID' do
it 'returns an Array of alerts' do
link['data-alert'] = alert.id.to_s
expect(subject.referenced_by([link])).to eq([alert])
end
end
context 'using a non-existing alert ID' do
it 'returns an empty Array' do
link['data-alert'] = ''
expect(subject.referenced_by([link])).to eq([])
end
end
end
end
end
|