debian-mirror-gitlab/spec/services/merge_requests/post_merge_service_spec.rb

40 lines
1.1 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe MergeRequests::PostMergeService do
2017-08-17 22:00:37 +05:30
let(:user) { create(:user) }
let(:merge_request) { create(:merge_request, assignee: user) }
let(:project) { merge_request.project }
before do
2018-03-17 18:26:18 +05:30
project.add_master(user)
2017-08-17 22:00:37 +05:30
end
describe '#execute' do
it_behaves_like 'cache counters invalidator'
2018-03-17 18:26:18 +05:30
it 'refreshes the number of open merge requests for a valid MR', :use_clean_rails_memory_store_caching do
# Cache the counter before the MR changed state.
project.open_merge_requests_count
merge_request.update!(state: 'merged')
service = described_class.new(project, user, {})
expect { service.execute(merge_request) }
.to change { project.open_merge_requests_count }.from(1).to(0)
end
it 'updates metrics' do
metrics = merge_request.metrics
metrics_service = double(MergeRequestMetricsService)
allow(MergeRequestMetricsService)
.to receive(:new)
.with(metrics)
.and_return(metrics_service)
expect(metrics_service).to receive(:merge)
described_class.new(project, user, {}).execute(merge_request)
end
2017-08-17 22:00:37 +05:30
end
end