gitlab-org--gitlab-foss/spec/services/update_merge_request_metrics_service_spec.rb
Ash McKenzie 19ff9d9899
Replace rails_helper.rb with spec_helper.rb
rails_helper.rb's only logic was to require
spec_helper.rb.
2019-08-30 12:26:18 +10:00

44 lines
1.1 KiB
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe MergeRequestMetricsService do
let(:metrics) { create(:merge_request).metrics }
describe '#merge' do
it 'updates metrics' do
user = create(:user)
service = described_class.new(metrics)
event = double(Event, author_id: user.id, created_at: Time.now)
service.merge(event)
expect(metrics.merged_by).to eq(user)
expect(metrics.merged_at).to be_like_time(event.created_at)
end
end
describe '#close' do
it 'updates metrics' do
user = create(:user)
service = described_class.new(metrics)
event = double(Event, author_id: user.id, created_at: Time.now)
service.close(event)
expect(metrics.latest_closed_by).to eq(user)
expect(metrics.latest_closed_at).to be_like_time(event.created_at)
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