2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'Groups > Members > Filter members' do
|
2020-01-01 13:55:28 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:nested_group_user) { create(:user) }
|
|
|
|
let(:user_with_2fa) { create(:user, :two_factor_via_otp) }
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:nested_group) { create(:group, parent: group) }
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
group.add_owner(user)
|
2018-11-18 11:00:15 +05:30
|
|
|
group.add_maintainer(user_with_2fa)
|
2020-01-01 13:55:28 +05:30
|
|
|
nested_group.add_maintainer(nested_group_user)
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows all members' do
|
2020-01-01 13:55:28 +05:30
|
|
|
visit_members_list(group)
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(member(0)).to include(user.name)
|
|
|
|
expect(member(1)).to include(user_with_2fa.name)
|
2019-10-12 21:52:04 +05:30
|
|
|
expect(page).to have_css('.member-filter-2fa-dropdown .dropdown-toggle-text', text: 'Everyone')
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows only 2FA members' do
|
2020-01-01 13:55:28 +05:30
|
|
|
visit_members_list(group, two_factor: 'enabled')
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(member(0)).to include(user_with_2fa.name)
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(members_list.size).to eq(1)
|
2019-10-12 21:52:04 +05:30
|
|
|
expect(page).to have_css('.member-filter-2fa-dropdown .dropdown-toggle-text', text: 'Enabled')
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows only non 2FA members' do
|
2020-01-01 13:55:28 +05:30
|
|
|
visit_members_list(group, two_factor: 'disabled')
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(member(0)).to include(user.name)
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(members_list.size).to eq(1)
|
2019-10-12 21:52:04 +05:30
|
|
|
expect(page).to have_css('.member-filter-2fa-dropdown .dropdown-toggle-text', text: 'Disabled')
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
it 'shows inherited members by default' do
|
|
|
|
visit_members_list(nested_group)
|
|
|
|
|
|
|
|
expect(member(0)).to include(user.name)
|
|
|
|
expect(member(1)).to include(user_with_2fa.name)
|
|
|
|
expect(member(2)).to include(nested_group_user.name)
|
|
|
|
expect(members_list.size).to eq(3)
|
|
|
|
|
|
|
|
expect(page).to have_css('[data-qa-selector="filter-members-with-inherited-permissions"] a.is-active', text: 'Show all members')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows only group members' do
|
|
|
|
visit_members_list(nested_group, with_inherited_permissions: 'exclude')
|
|
|
|
expect(member(0)).to include(nested_group_user.name)
|
|
|
|
expect(members_list.size).to eq(1)
|
|
|
|
expect(page).to have_css('[data-qa-selector="filter-members-with-inherited-permissions"] a.is-active', text: 'Show only direct members')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows only inherited members' do
|
|
|
|
visit_members_list(nested_group, with_inherited_permissions: 'only')
|
|
|
|
expect(member(0)).to include(user.name)
|
|
|
|
expect(member(1)).to include(user_with_2fa.name)
|
|
|
|
expect(members_list.size).to eq(2)
|
|
|
|
expect(page).to have_css('[data-qa-selector="filter-members-with-inherited-permissions"] a.is-active', text: 'Show only inherited members')
|
|
|
|
end
|
|
|
|
|
|
|
|
def visit_members_list(group, options = {})
|
2018-11-08 19:23:39 +05:30
|
|
|
visit group_group_members_path(group.to_param, options)
|
|
|
|
end
|
|
|
|
|
|
|
|
def members_list
|
|
|
|
page.all('ul.content-list > li')
|
|
|
|
end
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
def member(number)
|
|
|
|
members_list[number].text
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
end
|