debian-mirror-gitlab/spec/lib/banzai/reference_parser/milestone_parser_spec.rb

42 lines
1.1 KiB
Ruby
Raw Normal View History

require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe Banzai::ReferenceParser::MilestoneParser do
include ReferenceParserHelpers
2017-09-10 17:25:29 +05:30
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
let(:milestone) { create(:milestone, project: project) }
subject { described_class.new(project, user) }
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-milestone'] = milestone.id.to_s
end
2016-11-24 13:41:30 +05:30
it_behaves_like "referenced feature visibility", "issues", "merge_requests"
end
end
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