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

events_query_spec.rb « cycle_analytics « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a0da93dadeeb14196c59dbafcf441eaca6f18fc8 (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
32
33
34
35
require 'spec_helper'

describe Gitlab::CycleAnalytics::EventsQuery do
  let(:max_events) { 3 }
  let(:project) { create(:empty_project) }
  let(:user) { create(:user, :admin) }
  let(:options) { { from: 30.days.ago } }

  let(:issue_event) do
    Gitlab::CycleAnalytics::IssueEvent.new(project: project, options: options)
  end

  subject { described_class.new(project: project, options: options).execute(issue_event) }

  before do
    allow_any_instance_of(Gitlab::ReferenceExtractor).to receive(:issues).and_return(Issue.all)
    stub_const('Gitlab::CycleAnalytics::EventsQuery::MAX_EVENTS', max_events)

    setup_events(count: 5)
  end

  it 'limits the rows to the max number' do
    expect(subject.count).to eq(max_events)
  end

  def setup_events(count:)
    count.times do
      issue = create(:issue, project: project, created_at: 2.days.ago)
      milestone = create(:milestone, project: project)

      issue.update(milestone: milestone)
      create_merge_request_closing_issue(issue)
    end
  end
end