Commit c1d87cb1 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Add specs for Epics and Merge Requests

parent a4315e4f
......@@ -90,6 +90,35 @@ RSpec.describe EpicsFinder do
it 'returns all epics that match the search' do
expect(epics(search: 'awesome')).to contain_exactly(epic1, epic3)
end
context 'with anonymous user' do
let_it_be(:public_group) { create(:group, :public) }
let_it_be(:epic5) { create(:epic, group: public_group, title: 'tanuki') }
let_it_be(:epic6) { create(:epic, group: public_group, title: 'ikunat') }
let(:search_user) { nil }
let(:params) { { group_id: public_group.id, search: 'tanuki' } }
context 'with disable_anonymous_search feature flag enabled' do
before do
stub_feature_flags(disable_anonymous_search: true)
end
it 'does not perform search' do
expect(epics(params)).to contain_exactly(epic5, epic6)
end
end
context 'with disable_anonymous_search feature flag disabled' do
before do
stub_feature_flags(disable_anonymous_search: false)
end
it 'returns matching epics' do
expect(epics(params)).to contain_exactly(epic5)
end
end
end
end
context 'by user reaction emoji' do
......
......@@ -729,6 +729,36 @@ RSpec.describe MergeRequestsFinder do
merge_requests = described_class.new(user, params).execute
expect { merge_requests.load }.not_to raise_error
end
context 'filtering by search text' do
let!(:merge_request6) { create(:merge_request, source_project: project1, target_project: project1, source_branch: 'tanuki-branch', title: 'tanuki') }
let(:params) { { project_id: project1.id, search: 'tanuki' } }
context 'with anonymous user' do
let(:merge_requests) { described_class.new(nil, params).execute }
context 'with disable_anonymous_search feature flag enabled' do
before do
stub_feature_flags(disable_anonymous_search: true)
end
it 'does not perform search' do
expect(merge_requests).to contain_exactly(merge_request1, merge_request2, merge_request6)
end
end
context 'with disable_anonymous_search feature flag disabled' do
before do
stub_feature_flags(disable_anonymous_search: false)
end
it 'returns matching merge requests' do
expect(merge_requests).to contain_exactly(merge_request6)
end
end
end
end
end
describe '#row_count', :request_store do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment