BigW Consortium Gitlab

review_spec.rb 1.2 KB
Newer Older
1 2
require 'spec_helper'

3
describe 'CycleAnalytics#review' do
4 5
  extend CycleAnalyticsHelpers::TestGeneration

6
  let(:project) { create(:project, :repository) }
7 8
  let(:from_date) { 10.days.ago }
  let(:user) { create(:user, :admin) }
9
  subject { CycleAnalytics.new(project, from: from_date) }
10

11 12 13 14 15 16 17 18 19 20 21
  generate_cycle_analytics_spec(
    phase: :review,
    data_fn: -> (context) { { issue: context.create(:issue, project: context.project) } },
    start_time_conditions: [["merge request that closes issue is created",
                             -> (context, data) do
                               context.create_merge_request_closing_issue(data[:issue])
                             end]],
    end_time_conditions:   [["merge request that closes issue is merged",
                             -> (context, data) do
                               context.merge_merge_requests_closing_issue(data[:issue])
                             end]],
22
    post_fn: nil)
23 24 25

  context "when a regular merge request (that doesn't close the issue) is created and merged" do
    it "returns nil" do
26
      MergeRequests::MergeService.new(project, user).execute(create(:merge_request))
27

28
      expect(subject[:review].median).to be_nil
29 30 31
    end
  end
end