Welcome to mirror list, hosted at ThFree Co, Russian Federation.

synthetic_milestone_notes_builder_service_spec.rb « resource_events « services « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ca61afc7914d63f3d033d21d1dd0050a36bc8d1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ResourceEvents::SyntheticMilestoneNotesBuilderService, feature_category: :team_planning do
  describe '#execute' do
    let_it_be(:user) { create(:user) }
    let_it_be(:issue) { create(:issue, author: user) }
    let_it_be(:milestone) { create(:milestone, project: issue.project) }

    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')
      ]
    end

    it 'builds milestone notes for resource milestone events' do
      notes = described_class.new(issue, user).execute

      expect(notes.map(&:created_at)).to eq(events.map(&:created_at))
      expect(notes.map(&:note)).to eq(
        [
          "changed milestone to %#{milestone.iid}",
          'removed milestone'
        ])
    end

    it_behaves_like 'filters by paginated notes', :resource_milestone_event
  end
end