debian-mirror-gitlab/spec/services/update_merge_request_metrics_service_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
1.1 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2018-03-17 18:26:18 +05:30
2023-05-27 22:25:52 +05:30
RSpec.describe MergeRequestMetricsService, feature_category: :code_review_workflow do
2018-03-17 18:26:18 +05:30
let(:metrics) { create(:merge_request).metrics }
describe '#merge' do
it 'updates metrics' do
user = create(:user)
service = described_class.new(metrics)
2020-05-24 23:13:21 +05:30
event = double(Event, author_id: user.id, created_at: Time.current)
2018-03-17 18:26:18 +05:30
service.merge(event)
expect(metrics.merged_by).to eq(user)
2018-11-08 19:23:39 +05:30
expect(metrics.merged_at).to be_like_time(event.created_at)
2018-03-17 18:26:18 +05:30
end
end
describe '#close' do
it 'updates metrics' do
user = create(:user)
service = described_class.new(metrics)
2020-05-24 23:13:21 +05:30
event = double(Event, author_id: user.id, created_at: Time.current)
2018-03-17 18:26:18 +05:30
service.close(event)
expect(metrics.latest_closed_by).to eq(user)
2018-11-08 19:23:39 +05:30
expect(metrics.latest_closed_at).to be_like_time(event.created_at)
2018-03-17 18:26:18 +05:30
end
end
describe '#reopen' do
it 'updates metrics' do
service = described_class.new(metrics)
service.reopen
expect(metrics.latest_closed_by).to be_nil
expect(metrics.latest_closed_at).to be_nil
end
end
end