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
2020-07-28 23:09:34 +05:30
RSpec.describe MergeRequestMetricsService 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