This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 6119dcf Document parameters; ensure lists exist
6119dcf is described below
commit 6119dcf90d9fafecbce7a2b87909cd5e08eee281
Author: Sebb <[email protected]>
AuthorDate: Mon Mar 4 19:53:14 2019 +0000
Document parameters; ensure lists exist
ldap_pmcs also works for podlings
---
lib/spec/lib/mail/mail_spec.rb | 30 ++++++++++++++++++++++++++++++
lib/whimsy/asf/mail.rb | 8 ++++++--
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/lib/spec/lib/mail/mail_spec.rb b/lib/spec/lib/mail/mail_spec.rb
index 82ca6e5..6c2e8dd 100644
--- a/lib/spec/lib/mail/mail_spec.rb
+++ b/lib/spec/lib/mail/mail_spec.rb
@@ -22,4 +22,34 @@ describe ASF::Mail do
end
end
+ describe '.cansub(member, pmc_chair, ldap_pmcs)' do
+ lists = ASF::Mail.cansub(false, false, nil)
+ it 'should return public lists only' do
+ whitelist = ['infra-users', 'jobs', 'site-dev', 'committers-cvs',
'site-cvs', 'concom', 'party']
+ board = ['board', 'board-commits', 'board-chat']
+ expect(lists.length).to be >= 1000
+ expect(lists).not_to include('private')
+ expect(lists).not_to include('security')
+ expect(lists).to include(*whitelist)
+ expect(lists).not_to include(*board)
+ end
+ it 'should return the same lists' do
+ mylists = ASF::Mail.cansub(false, false, []) - lists
+ expect(mylists.length).to be(0)
+ end
+ it 'should return private PMC lists' do
+ mylists = ASF::Mail.cansub(false, false, ['ant','whimsical']) - lists
+ expect(mylists.length).to be(2)
+ expect(mylists).to include('ant-private','whimsical-private')
+ end
+ it 'should not return non-existent lists' do
+ mylists = ASF::Mail.cansub(false, false, ['xxxant','xxxwhimsical']) -
lists
+ expect(mylists.length).to be(0)
+ end
+ it 'should return private PPMC lists' do
+ podnames = ASF::Podling.current.map(&:name)
+ mylists = ASF::Mail.cansub(false, false, podnames) - lists
+ expect(mylists.length).to be(podnames.length)
+ end
+ end
end
diff --git a/lib/whimsy/asf/mail.rb b/lib/whimsy/asf/mail.rb
index 7ce7a97..87300d4 100644
--- a/lib/whimsy/asf/mail.rb
+++ b/lib/whimsy/asf/mail.rb
@@ -71,6 +71,9 @@ module ASF
end
# which lists are available for subscription via Whimsy?
+ # member: true if member
+ # pmc_chair: true if pmc_chair
+ # ldap_pmcs: list of (P)PMC mail_list names
def self.cansub(member, pmc_chair, ldap_pmcs)
Mail._load_lists
if member
@@ -89,9 +92,10 @@ module ASF
lists += ['board', 'board-commits', 'board-chat']
end
- # PMC members need their private lists
+ # (P)PMC members need their private lists
if ldap_pmcs
- lists += ldap_pmcs.map {|lp| "#{lp}-private"}
+ # ensure that the lists actually exist
+ lists += ldap_pmcs.map {|lp| "#{lp}-private"}.select{|l|
@lists.keys.include? l}
end
lists