-
Notifications
You must be signed in to change notification settings - Fork 993
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #36891 - Provide a scope for email-notification-eligible users
- Loading branch information
1 parent
5a3d323
commit 2233c33
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,6 +172,27 @@ def setup | |
assert_valid u | ||
end | ||
|
||
test ".with_enabled_email gives only the right users" do | ||
# Mail enabled | ||
u1 = FactoryBot.create(:user, :mail => '[email protected]', :mail_enabled => nil) | ||
u2 = FactoryBot.create(:user, :mail => '[email protected]', :mail_enabled => '') | ||
assert User.with_enabled_email.where(login: [u1, u2].map(&:login)).empty? | ||
|
||
# Mail missing | ||
u1 = FactoryBot.create(:user, :mail => '', :mail_enabled => true) | ||
u2 = FactoryBot.create(:user, :mail => nil, :mail_enabled => true) | ||
assert User.with_enabled_email.where(login: [u1, u2].map(&:login)).empty? | ||
|
||
# Disabled | ||
u1 = FactoryBot.create(:user, :mail => '[email protected]', :mail_enabled => true, :disabled => false) | ||
u2 = FactoryBot.create(:user, :mail => '[email protected]', :mail_enabled => true, :disabled => nil) | ||
u3 = FactoryBot.create(:user, :mail => '[email protected]', :mail_enabled => true, :disabled => true) | ||
actual = User.with_enabled_email.where(login: [u1, u2, u3].map(&:login)) | ||
assert_includes actual, u1 | ||
assert_includes actual, u2 | ||
assert_equal actual.count, 2 | ||
end | ||
|
||
test 'login should also be unique across usergroups' do | ||
Usergroup.expects(:where).with(:name => 'foo').returns(['fakeusergroup']) | ||
u = FactoryBot.build_stubbed(:user, :auth_source => auth_sources(:one), | ||
|