diff options
author | Alexis Reigel <mail@koffeinfrei.org> | 2017-03-09 20:38:13 +0100 |
---|---|---|
committer | Alexis Reigel <mail@koffeinfrei.org> | 2017-04-06 10:01:14 +0200 |
commit | 20575859b1bf431421427d52c4ac5a33cf662df6 (patch) | |
tree | 54f8ac4eca2b8239530a956cac65c7378e5c7d97 /spec/models | |
parent | 5ea4e34f4755e9a15503a6f16fd1574dc7864b23 (diff) | |
download | gitlab-ce-20575859b1bf431421427d52c4ac5a33cf662df6.tar.gz |
check all groups for 2fa requirement
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/user_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b2f686a1819..ddd438bfc25 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1407,6 +1407,17 @@ describe User, models: true do it { expect(user.nested_groups).to eq([nested_group]) } end + describe '#all_expanded_groups' do + let!(:user) { create(:user) } + let!(:group) { create(:group) } + let!(:nested_group_1) { create(:group, parent: group) } + let!(:nested_group_2) { create(:group, parent: group) } + + before { nested_group_1.add_owner(user) } + + it { expect(user.all_expanded_groups).to match_array [group, nested_group_1] } + end + describe '#nested_groups_projects' do let!(:user) { create(:user) } let!(:group) { create(:group) } @@ -1545,6 +1556,36 @@ describe User, models: true do end end + context 'with 2FA requirement on nested parent group' do + let!(:group1) { create :group, require_two_factor_authentication: true } + let!(:group1a) { create :group, require_two_factor_authentication: false, parent: group1 } + + before do + group1a.add_user(user, GroupMember::OWNER) + + user.update_two_factor_requirement + end + + it 'requires 2FA' do + expect(user.require_two_factor_authentication).to be true + end + end + + context 'with 2FA requirement on nested child group' do + let!(:group1) { create :group, require_two_factor_authentication: false } + let!(:group1a) { create :group, require_two_factor_authentication: true, parent: group1 } + + before do + group1.add_user(user, GroupMember::OWNER) + + user.update_two_factor_requirement + end + + it 'requires 2FA' do + expect(user.require_two_factor_authentication).to be true + end + end + context 'without 2FA requirement on groups' do let(:group) { create :group } |