Commit dfa8233b authored by Phil Hughes's avatar Phil Hughes Committed by Igor Drozdov

Fixes the ability to filter target branch by not equal

This fixes the target branch filter in merge requests to allow
the user to filter by not equal.
parent f71c1719
......@@ -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