BigW Consortium Gitlab

milestone_parser_spec.rb 1.14 KB
Newer Older
1 2
require 'spec_helper'

3
describe Banzai::ReferenceParser::MilestoneParser do
4 5
  include ReferenceParserHelpers

6
  let(:project) { create(:project, :public) }
7 8 9 10 11
  let(:user) { create(:user) }
  let(:milestone) { create(:milestone, project: project) }
  subject { described_class.new(project, user) }
  let(:link) { empty_html_link }

12 13
  describe '#nodes_visible_to_user' do
    context 'when the link has a data-issue attribute' do
14 15 16
      before do
        link['data-milestone'] = milestone.id.to_s
      end
17 18 19 20 21

      it_behaves_like "referenced feature visibility", "issues", "merge_requests"
    end
  end

22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
  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