diff options
author | Manoj MJ <mmj@gitlab.com> | 2019-08-31 00:30:51 +0300 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2019-08-31 00:30:51 +0300 |
commit | b943baa42a5365bd6377022223f66db9af58da33 (patch) | |
tree | 60baf4cdcce1176d6a92ede78000a42e3d46d288 /spec/models/group_spec.rb | |
parent | 663b7bb4771f3261d7451b6e1d74c778fd0e3589 (diff) |
Limit access request email to 10 most recently active owners/maintainers
This change limits the number of emails
for new access requests notifications to
10 most recently active owners/maintainers
Diffstat (limited to 'spec/models/group_spec.rb')
-rw-r--r-- | spec/models/group_spec.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 1c41ceb7deb..796b6917fb2 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -1039,4 +1039,23 @@ describe Group do .to eq(Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS) end end + + describe '#access_request_approvers_to_be_notified' do + it 'returns a maximum of ten, active, non_requested owners of the group in recent_sign_in descending order' do + group = create(:group, :public) + + users = create_list(:user, 12, :with_sign_ins) + active_owners = users.map do |user| + create(:group_member, :owner, group: group, user: user) + end + + create(:group_member, :owner, :blocked, group: group) + create(:group_member, :maintainer, group: group) + create(:group_member, :access_request, :owner, group: group) + + active_owners_in_recent_sign_in_desc_order = group.members_and_requesters.where(id: active_owners).order_recent_sign_in.limit(10) + + expect(group.access_request_approvers_to_be_notified).to eq(active_owners_in_recent_sign_in_desc_order) + end + end end |