FIX: Automatic group membership should not add staged or unactivated users.
This commit is contained in:
parent
12407484d8
commit
7228081820
|
@ -15,6 +15,7 @@ module Jobs
|
|||
|
||||
User.where("email ~* '@(#{domains})$'")
|
||||
.where("users.id NOT IN (SELECT user_id FROM group_users WHERE group_users.group_id = ?)", group_id)
|
||||
.where(staged: false)
|
||||
.find_each do |user|
|
||||
|
||||
group.add(user)
|
||||
|
|
|
@ -10,6 +10,7 @@ describe Jobs::AutomaticGroupMembership do
|
|||
it "updates the membership" do
|
||||
user1 = Fabricate(:user, email: "foo@wat.com")
|
||||
user2 = Fabricate(:user, email: "foo@bar.com")
|
||||
user3 = Fabricate(:user, email: "bar@wat.com", staged: true)
|
||||
group = Fabricate(:group, automatic_membership_email_domains: "wat.com", automatic_membership_retroactive: true)
|
||||
|
||||
Jobs::AutomaticGroupMembership.new.execute(group_id: group.id)
|
||||
|
@ -17,6 +18,7 @@ describe Jobs::AutomaticGroupMembership do
|
|||
group.reload
|
||||
expect(group.users.include?(user1)).to eq(true)
|
||||
expect(group.users.include?(user2)).to eq(false)
|
||||
expect(group.users.include?(user3)).to eq(false)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue