Commit 6002ccef authored by Patrick Bajao's avatar Patrick Bajao

Merge branch 'id-extract-approvals-feature-to-ce' into 'master'

Move filter-by-approvals feature to FOSS

See merge request gitlab-org/gitlab!44402
parents b1dca81c d774fdd9
......@@ -5,21 +5,21 @@ require 'spec_helper'
RSpec.describe 'Merge Requests > User filters', :js do
include FilteredSearchHelpers
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:group_user) { create(:user) }
let(:first_user) { create(:user) }
let_it_be(:project) { create(:project, :public, :repository) }
let_it_be(:user) { project.creator }
let_it_be(:group_user) { create(:user) }
let_it_be(:first_user) { create(:user) }
let!(:merge_request_with_approver) do
let_it_be(:merge_request_with_approver) do
create(:merge_request, approval_users: [first_user], title: 'Bugfix1', source_project: project, source_branch: 'bugfix1')
end
let!(:merge_request_with_two_approvers) do
let_it_be(:merge_request_with_two_approvers) do
create(:merge_request, title: 'Bugfix2', approval_users: [user, first_user], source_project: project, source_branch: 'bugfix2')
end
let!(:merge_request) { create(:merge_request, title: 'Bugfix3', source_project: project, source_branch: 'bugfix3') }
let!(:merge_request_with_group_approver) do
let_it_be(:merge_request) { create(:merge_request, title: 'Bugfix3', source_project: project, source_branch: 'bugfix3') }
let_it_be(:merge_request_with_group_approver) do
group = create(:group)
group.add_developer(group_user)
......@@ -97,66 +97,4 @@ RSpec.describe 'Merge Requests > User filters', :js do
end
end
end
context 'by "approved by"' do
let!(:merge_request_with_first_user_approval) do
create(:merge_request, source_project: project, title: 'Bugfix5').tap do |mr|
create(:approval, merge_request: mr, user: first_user)
end
end
let!(:merge_request_with_group_user_approved) do
group = create(:group)
group.add_developer(group_user)
create(:merge_request, source_project: project, title: 'Bugfix6', approval_groups: [group], source_branch: 'bugfix6').tap do |mr|
create(:approval, merge_request: mr, user: group_user)
end
end
context 'filtering by approved-by:none' do
it 'applies the filter' do
input_filtered_search('approved-by:=none')
expect(page).to have_issuable_counts(open: 4, closed: 0, all: 4)
expect(page).not_to have_content 'Bugfix5'
expect(page).to have_content 'Bugfix3'
end
end
context 'filtering by approved-by:any' do
it 'applies the filter' do
input_filtered_search('approved-by:=any')
expect(page).to have_issuable_counts(open: 2, closed: 0, all: 2)
expect(page).to have_content 'Bugfix5'
expect(page).not_to have_content 'Bugfix3'
end
end
context 'filtering by approved-by:@username' do
it 'applies the filter' do
input_filtered_search("approved-by:=@#{first_user.username}")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
expect(page).to have_content 'Bugfix5'
expect(page).not_to have_content 'Bugfix3'
end
end
context 'filtering by an approver from a group' do
it 'applies the filter' do
input_filtered_search("approved-by:=@#{group_user.username}")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
expect(page).to have_content 'Bugfix6'
expect(page).not_to have_content 'Bugfix5'
expect(page).not_to have_content 'Bugfix3'
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Merge Requests > User filters', :js do
include FilteredSearchHelpers
let_it_be(:project) { create(:project, :public, :repository) }
let_it_be(:user) { project.creator }
let_it_be(:group_user) { create(:user) }
let_it_be(:first_user) { create(:user) }
before do
sign_in(user)
visit project_merge_requests_path(project)
end
context 'by "approved by"' do
let_it_be(:merge_request) { create(:merge_request, title: 'Bugfix3', source_project: project, source_branch: 'bugfix3') }
let_it_be(:merge_request_with_first_user_approval) do
create(:merge_request, source_project: project, title: 'Bugfix5').tap do |mr|
create(:approval, merge_request: mr, user: first_user)
end
end
let_it_be(:merge_request_with_group_user_approved) do
group = create(:group)
group.add_developer(group_user)
create(:merge_request, source_project: project, title: 'Bugfix6', source_branch: 'bugfix6').tap do |mr|
create(:approval, merge_request: mr, user: group_user)
end
end
context 'filtering by approved-by:none' do
it 'applies the filter' do
input_filtered_search('approved-by:=none')
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
expect(page).not_to have_content 'Bugfix5'
expect(page).not_to have_content 'Bugfix6'
expect(page).to have_content 'Bugfix3'
end
end
context 'filtering by approved-by:any' do
it 'applies the filter' do
input_filtered_search('approved-by:=any')
expect(page).to have_issuable_counts(open: 2, closed: 0, all: 2)
expect(page).to have_content 'Bugfix5'
expect(page).not_to have_content 'Bugfix3'
end
end
context 'filtering by approved-by:@username' do
it 'applies the filter' do
input_filtered_search("approved-by:=@#{first_user.username}")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
expect(page).to have_content 'Bugfix5'
expect(page).not_to have_content 'Bugfix3'
end
end
context 'filtering by an approver from a group' do
it 'applies the filter' do
input_filtered_search("approved-by:=@#{group_user.username}")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
expect(page).to have_content 'Bugfix6'
expect(page).not_to have_content 'Bugfix5'
expect(page).not_to have_content 'Bugfix3'
end
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