2021-04-29 21:17:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
RSpec.describe Groups::MergeRequestsCountService, :use_clean_rails_memory_store_caching, feature_category: :subgroups do
|
2021-04-29 21:17:54 +05:30
|
|
|
let_it_be(:user) { create(:user) }
|
2022-08-27 11:52:29 +05:30
|
|
|
let_it_be(:group) { create(:group, :public) }
|
2021-04-29 21:17:54 +05:30
|
|
|
let_it_be(:project) { create(:project, :repository, namespace: group) }
|
|
|
|
let_it_be(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
|
|
|
|
|
|
|
|
subject { described_class.new(group, user) }
|
|
|
|
|
|
|
|
describe '#relation_for_count' do
|
|
|
|
before do
|
|
|
|
group.add_reporter(user)
|
|
|
|
allow(MergeRequestsFinder).to receive(:new).and_call_original
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'uses the MergeRequestsFinder to scope merge requests' do
|
|
|
|
expect(MergeRequestsFinder)
|
|
|
|
.to receive(:new)
|
|
|
|
.with(user, group_id: group.id, state: 'opened', non_archived: true, include_subgroups: true)
|
|
|
|
|
|
|
|
subject.count
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'a counter caching service with threshold'
|
|
|
|
end
|