2013-06-17 10:07:16 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 14:24:02 +00:00
|
|
|
describe GroupMember do
|
2016-09-16 15:54:21 +00:00
|
|
|
describe '.access_level_roles' do
|
|
|
|
it 'returns Gitlab::Access.options_with_owner' do
|
|
|
|
expect(described_class.access_level_roles).to eq(Gitlab::Access.options_with_owner)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.access_levels' do
|
|
|
|
it 'returns Gitlab::Access.options_with_owner' do
|
|
|
|
expect(described_class.access_levels).to eq(Gitlab::Access.sym_options_with_owner)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-04-21 14:07:42 +00:00
|
|
|
describe '.add_users' do
|
2016-09-16 15:54:21 +00:00
|
|
|
it 'adds the given users to the given group' do
|
|
|
|
group = create(:group)
|
|
|
|
users = create_list(:user, 2)
|
|
|
|
|
2017-04-21 14:07:42 +00:00
|
|
|
described_class.add_users(
|
2016-09-16 15:54:21 +00:00
|
|
|
group,
|
|
|
|
[users.first.id, users.second],
|
|
|
|
described_class::MASTER
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(group.users).to include(users.first, users.second)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-23 14:38:37 +00:00
|
|
|
it_behaves_like 'members notifications', :group
|
2015-05-21 21:49:06 +00:00
|
|
|
|
2018-04-23 14:38:37 +00:00
|
|
|
describe '#real_source_type' do
|
|
|
|
subject { create(:group_member).real_source_type }
|
2015-05-21 21:49:06 +00:00
|
|
|
|
2018-04-23 14:38:37 +00:00
|
|
|
it { is_expected.to eq 'Group' }
|
2014-06-17 18:36:40 +00:00
|
|
|
end
|
2017-01-24 21:09:58 +00:00
|
|
|
|
|
|
|
describe '#update_two_factor_requirement' do
|
|
|
|
let(:user) { build :user }
|
|
|
|
let(:group_member) { build :group_member, user: user }
|
|
|
|
|
|
|
|
it 'is called after creation and deletion' do
|
|
|
|
expect(user).to receive(:update_two_factor_requirement)
|
|
|
|
|
|
|
|
group_member.save
|
|
|
|
|
|
|
|
expect(user).to receive(:update_two_factor_requirement)
|
|
|
|
|
|
|
|
group_member.destroy
|
|
|
|
end
|
|
|
|
end
|
2013-06-17 10:07:16 +00:00
|
|
|
end
|