2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe Banzai::ReferenceParser::LabelParser do
|
2016-06-16 23:09:34 +05:30
|
|
|
include ReferenceParserHelpers
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project, :public) }
|
2016-06-16 23:09:34 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:label) { create(:label, project: project) }
|
2018-05-09 12:01:36 +05:30
|
|
|
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
|
2016-06-16 23:09:34 +05:30
|
|
|
let(:link) { empty_html_link }
|
|
|
|
|
2016-11-24 13:41:30 +05:30
|
|
|
describe '#nodes_visible_to_user' do
|
|
|
|
context 'when the link has a data-issue attribute' do
|
2017-09-10 17:25:29 +05:30
|
|
|
before do
|
|
|
|
link['data-label'] = label.id.to_s
|
|
|
|
end
|
2016-11-24 13:41:30 +05:30
|
|
|
|
|
|
|
it_behaves_like "referenced feature visibility", "issues", "merge_requests"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
describe '#referenced_by' do
|
|
|
|
describe 'when the link has a data-label attribute' do
|
|
|
|
context 'using an existing label ID' do
|
|
|
|
it 'returns an Array of labels' do
|
|
|
|
link['data-label'] = label.id.to_s
|
|
|
|
|
|
|
|
expect(subject.referenced_by([link])).to eq([label])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'using a non-existing label ID' do
|
|
|
|
it 'returns an empty Array' do
|
|
|
|
link['data-label'] = ''
|
|
|
|
|
|
|
|
expect(subject.referenced_by([link])).to eq([])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|