2020-04-08 14:13:33 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
RSpec.describe ResourceMilestoneEvent, feature_category: :team_planning, type: :model do
|
2020-04-08 14:13:33 +05:30
|
|
|
it_behaves_like 'a resource event'
|
|
|
|
it_behaves_like 'a resource event for issues'
|
|
|
|
it_behaves_like 'a resource event for merge requests'
|
2023-03-17 16:20:25 +05:30
|
|
|
it_behaves_like 'a note for work item resource event'
|
2020-04-08 14:13:33 +05:30
|
|
|
|
|
|
|
it_behaves_like 'having unique enum values'
|
2020-10-24 23:57:45 +05:30
|
|
|
it_behaves_like 'timebox resource event validations'
|
|
|
|
it_behaves_like 'timebox resource event states'
|
|
|
|
it_behaves_like 'timebox resource event actions'
|
2021-01-03 14:25:43 +05:30
|
|
|
it_behaves_like 'timebox resource tracks issue metrics', :milestone
|
2020-04-08 14:13:33 +05:30
|
|
|
|
|
|
|
describe 'associations' do
|
|
|
|
it { is_expected.to belong_to(:milestone) }
|
|
|
|
end
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
describe '#milestone_title' do
|
|
|
|
let(:milestone) { create(:milestone, title: 'v2.3') }
|
|
|
|
let(:event) { create(:resource_milestone_event, milestone: milestone) }
|
|
|
|
|
|
|
|
it 'returns the expected title' do
|
|
|
|
expect(event.milestone_title).to eq('v2.3')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when milestone is nil' do
|
|
|
|
let(:event) { create(:resource_milestone_event, milestone: nil) }
|
|
|
|
|
|
|
|
it 'returns nil' do
|
|
|
|
expect(event.milestone_title).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
describe '#milestone_parent' do
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
|
|
|
|
let(:milestone) { create(:milestone, project: project) }
|
|
|
|
let(:event) { create(:resource_milestone_event, milestone: milestone) }
|
|
|
|
|
|
|
|
context 'when milestone parent is project' do
|
|
|
|
it 'returns the expected parent' do
|
|
|
|
expect(event.milestone_parent).to eq(project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when milestone parent is group' do
|
|
|
|
let(:milestone) { create(:milestone, group: group) }
|
|
|
|
|
|
|
|
it 'returns the expected parent' do
|
|
|
|
expect(event.milestone_parent).to eq(group)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when milestone is nil' do
|
|
|
|
let(:event) { create(:resource_milestone_event, milestone: nil) }
|
|
|
|
|
|
|
|
it 'returns nil' do
|
|
|
|
expect(event.milestone_parent).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|