2016-05-26 07:16:43 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Banzai::ReferenceParser::MilestoneParser do
|
2016-05-26 07:16:43 -04:00
|
|
|
include ReferenceParserHelpers
|
|
|
|
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :public) }
|
2016-05-26 07:16:43 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:milestone) { create(:milestone, project: project) }
|
2018-04-03 09:45:17 -04:00
|
|
|
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
|
2016-05-26 07:16:43 -04:00
|
|
|
let(:link) { empty_html_link }
|
|
|
|
|
2016-11-01 16:18:51 -04:00
|
|
|
describe '#nodes_visible_to_user' do
|
|
|
|
context 'when the link has a data-issue attribute' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
link['data-milestone'] = milestone.id.to_s
|
|
|
|
end
|
2016-11-01 16:18:51 -04:00
|
|
|
|
|
|
|
it_behaves_like "referenced feature visibility", "issues", "merge_requests"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-05-26 07:16:43 -04:00
|
|
|
describe '#referenced_by' do
|
|
|
|
describe 'when the link has a data-milestone attribute' do
|
|
|
|
context 'using an existing milestone ID' do
|
|
|
|
it 'returns an Array of milestones' do
|
|
|
|
link['data-milestone'] = milestone.id.to_s
|
|
|
|
|
|
|
|
expect(subject.referenced_by([link])).to eq([milestone])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'using a non-existing milestone ID' do
|
|
|
|
it 'returns an empty Array' do
|
|
|
|
link['data-milestone'] = ''
|
|
|
|
|
|
|
|
expect(subject.referenced_by([link])).to eq([])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|