2020-04-22 19:07:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe ResourceEvents::SyntheticMilestoneNotesBuilderService do
|
2020-04-22 19:07:51 +05:30
|
|
|
describe '#execute' do
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:issue) { create(:issue, author: user) }
|
2020-11-24 15:15:51 +05:30
|
|
|
let_it_be(:milestone) { create(:milestone, project: issue.project) }
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
let_it_be(:events) do
|
|
|
|
[
|
|
|
|
create(:resource_milestone_event, issue: issue, milestone: milestone, action: :add, created_at: '2020-01-01 04:00'),
|
|
|
|
create(:resource_milestone_event, issue: issue, milestone: milestone, action: :remove, created_at: '2020-01-02 08:00')
|
|
|
|
]
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
it 'builds milestone notes for resource milestone events' do
|
|
|
|
notes = described_class.new(issue, user).execute
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(notes.map(&:created_at)).to eq(events.map(&:created_at))
|
2022-11-25 23:54:43 +05:30
|
|
|
expect(notes.map(&:note)).to eq(
|
|
|
|
[
|
|
|
|
"changed milestone to %#{milestone.iid}",
|
|
|
|
'removed milestone'
|
|
|
|
])
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
2021-12-11 22:18:48 +05:30
|
|
|
|
|
|
|
it_behaves_like 'filters by paginated notes', :resource_milestone_event
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
end
|