Commit 8abe1811 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'ph/filterTargetBranchByNotEquals' into 'master'

Fixes the ability to filter target branch by not equal

See merge request gitlab-org/gitlab!45652
parents 9c99875c dfa8233b
......@@ -66,6 +66,11 @@ class MergeRequestsFinder < IssuableFinder
by_source_project_id(items)
end
def filter_negated_items(items)
items = super(items)
by_negated_target_branch(items)
end
private
def by_commit(items)
......@@ -98,6 +103,14 @@ class MergeRequestsFinder < IssuableFinder
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def by_negated_target_branch(items)
return items unless not_params[:target_branch]
items.where.not(target_branch: not_params[:target_branch])
end
# rubocop: enable CodeReuse/ActiveRecord
def source_project_id
@source_project_id ||= params[:source_project_id].presence
end
......
---
title: Fixed target branch not filtering
merge_request: 45652
author:
type: fixed
......@@ -44,4 +44,14 @@ RSpec.describe 'Merge Requests > User filters by target branch', :js do
expect(page).not_to have_content mr2.title
end
end
context 'filtering by target-branch:!=master' do
it 'applies the filter' do
input_filtered_search('target-branch:!=master')
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
expect(page).not_to have_content mr1.title
expect(page).to have_content mr2.title
end
end
end
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