2019-05-23 14:07:59 -04:00
# frozen_string_literal: true
2016-10-26 13:34:06 -04:00
require 'spec_helper'
2020-06-16 14:09:01 -04:00
RSpec . describe 'Group merge requests page' do
2017-08-27 02:41:42 -04:00
include FilteredSearchHelpers
2016-10-26 13:34:06 -04:00
let ( :path ) { merge_requests_group_path ( group ) }
2016-11-27 05:33:15 -05:00
let ( :issuable ) { create ( :merge_request , source_project : project , target_project : project , title : 'this is my created issuable' ) }
2018-03-17 04:29:05 -04:00
let ( :access_level ) { ProjectFeature :: ENABLED }
let ( :user ) { user_in_group }
2016-10-26 13:34:06 -04:00
include_examples 'project features apply to issuables' , MergeRequest
2016-11-27 05:33:15 -05:00
context 'archived issuable' do
2017-07-21 17:00:42 -04:00
let ( :project_archived ) { create ( :project , :archived , :merge_requests_enabled , :repository , group : group ) }
2016-11-27 05:33:15 -05:00
let ( :issuable_archived ) { create ( :merge_request , source_project : project_archived , target_project : project_archived , title : 'issuable of an archived project' ) }
before do
issuable_archived
visit path
end
it 'hides archived merge requests' do
expect ( page ) . to have_content ( issuable . title )
expect ( page ) . not_to have_content ( issuable_archived . title )
end
it 'ignores archived merge request count badges in navbar' do
2021-04-01 05:09:05 -04:00
expect ( first ( :link , text : 'Merge requests' ) . find ( '.badge' ) . text ) . to eq ( " 1 " )
2016-11-27 05:33:15 -05:00
end
it 'ignores archived merge request count badges in state-filters' do
expect ( page . find ( '#state-opened span.badge' ) . text ) . to eq ( " 1 " )
expect ( page . find ( '#state-merged span.badge' ) . text ) . to eq ( " 0 " )
expect ( page . find ( '#state-closed span.badge' ) . text ) . to eq ( " 0 " )
expect ( page . find ( '#state-all span.badge' ) . text ) . to eq ( " 1 " )
end
end
2017-08-27 02:41:42 -04:00
2018-03-17 04:29:05 -04:00
context 'when merge request assignee to user' do
before do
2019-04-07 14:35:16 -04:00
issuable . update! ( assignees : [ user ] )
2018-03-17 04:29:05 -04:00
visit path
end
it { expect ( page ) . to have_content issuable . title [ 0 .. 80 ] }
end
2017-08-27 02:41:42 -04:00
context 'group filtered search' , :js do
let ( :user2 ) { user_outside_group }
it 'filters by assignee only group users' do
2020-03-04 04:08:20 -05:00
filtered_search . set ( 'assignee:=' )
2017-08-27 02:41:42 -04:00
expect ( find ( '#js-dropdown-assignee .filter-dropdown' ) ) . to have_content ( user . name )
expect ( find ( '#js-dropdown-assignee .filter-dropdown' ) ) . not_to have_content ( user2 . name )
end
end
2018-07-02 04:04:43 -04:00
describe 'new merge request dropdown' do
let ( :project_with_merge_requests_disabled ) { create ( :project , :merge_requests_disabled , group : group ) }
before do
visit path
end
it 'shows projects only with merge requests feature enabled' , :js do
find ( '.new-project-item-link' ) . click
page . within ( '.select2-results' ) do
expect ( page ) . to have_content ( project . name_with_namespace )
expect ( page ) . not_to have_content ( project_with_merge_requests_disabled . name_with_namespace )
end
end
end
2016-10-26 13:34:06 -04:00
end