Merge pull request #5013 from LeoMcA/alternate-emails-phase-1.5
FIX: add additional email to tests and clean up resulting mess
This commit is contained in:
commit
b77aa29e71
|
@ -37,6 +37,7 @@ class Admin::GroupsController < Admin::AdminController
|
||||||
valid_emails[email] = valid_usernames[username_lower] = id
|
valid_emails[email] = valid_usernames[username_lower] = id
|
||||||
id
|
id
|
||||||
end
|
end
|
||||||
|
valid_users.uniq!
|
||||||
invalid_users = users.reject! { |u| valid_emails[u] || valid_usernames[u] }
|
invalid_users = users.reject! { |u| valid_emails[u] || valid_usernames[u] }
|
||||||
group.bulk_add(valid_users) if valid_users.present?
|
group.bulk_add(valid_users) if valid_users.present?
|
||||||
users_added = valid_users.count
|
users_added = valid_users.count
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Jobs
|
||||||
query = query.where('users.created_at < ?', SiteSetting.pending_users_reminder_delay.hours.ago)
|
query = query.where('users.created_at < ?', SiteSetting.pending_users_reminder_delay.hours.ago)
|
||||||
end
|
end
|
||||||
|
|
||||||
newest_username = query.limit(1).pluck(:username).first
|
newest_username = query.limit(1).select(:username).first&.username
|
||||||
|
|
||||||
return true if newest_username == previous_newest_username # already notified
|
return true if newest_username == previous_newest_username # already notified
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@ class AdminUserIndexQuery
|
||||||
|
|
||||||
def initialize(params = {}, klass = User, trust_levels = TrustLevel.levels)
|
def initialize(params = {}, klass = User, trust_levels = TrustLevel.levels)
|
||||||
@params = params
|
@params = params
|
||||||
@query = initialize_query_with_order(klass).joins(:user_emails)
|
@outer_query = initialize_query_with_order(klass)
|
||||||
|
@query = klass.joins(:user_emails).distinct
|
||||||
@trust_levels = trust_levels
|
@trust_levels = trust_levels
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -134,7 +135,7 @@ class AdminUserIndexQuery
|
||||||
append filter_by_ip
|
append filter_by_ip
|
||||||
append filter_exclude
|
append filter_exclude
|
||||||
append filter_by_search
|
append filter_by_search
|
||||||
@query
|
@outer_query.from(@query, 'users')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,3 +2,8 @@ Fabricator(:user_email) do
|
||||||
email { sequence(:email) { |i| "bruce#{i}@wayne.com" } }
|
email { sequence(:email) { |i| "bruce#{i}@wayne.com" } }
|
||||||
primary true
|
primary true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Fabricator(:alternate_email, from: :user_email) do
|
||||||
|
email { sequence(:email) { |i| "bwayne#{i}@wayne.com" } }
|
||||||
|
primary false
|
||||||
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Fabricator(:user_stat) do
|
Fabricator(:user_stat) do
|
||||||
end
|
end
|
||||||
|
|
||||||
Fabricator(:user) do
|
Fabricator(:user_single_email, class_name: :user) do
|
||||||
name 'Bruce Wayne'
|
name 'Bruce Wayne'
|
||||||
username { sequence(:username) { |i| "bruce#{i}" } }
|
username { sequence(:username) { |i| "bruce#{i}" } }
|
||||||
email { sequence(:email) { |i| "bruce#{i}@wayne.com" } }
|
email { sequence(:email) { |i| "bruce#{i}@wayne.com" } }
|
||||||
|
@ -11,6 +11,10 @@ Fabricator(:user) do
|
||||||
active true
|
active true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Fabricator(:user, from: :user_single_email) do
|
||||||
|
after_create { |user| Fabricate(:alternate_email, user: user) }
|
||||||
|
end
|
||||||
|
|
||||||
Fabricator(:coding_horror, from: :user) do
|
Fabricator(:coding_horror, from: :user) do
|
||||||
name 'Coding Horror'
|
name 'Coding Horror'
|
||||||
username 'CodingHorror'
|
username 'CodingHorror'
|
||||||
|
|
|
@ -615,7 +615,7 @@ describe User do
|
||||||
|
|
||||||
it 'email whitelist should be used when email is being changed' do
|
it 'email whitelist should be used when email is being changed' do
|
||||||
SiteSetting.email_domains_whitelist = 'vaynermedia.com'
|
SiteSetting.email_domains_whitelist = 'vaynermedia.com'
|
||||||
u = Fabricate(:user, email: 'good@vaynermedia.com')
|
u = Fabricate(:user_single_email, email: 'good@vaynermedia.com')
|
||||||
u.email = 'nope@mailinator.com'
|
u.email = 'nope@mailinator.com'
|
||||||
expect(u).not_to be_valid
|
expect(u).not_to be_valid
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,10 +53,10 @@ describe UserDestroyer do
|
||||||
destroy
|
destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds email to block list if block_email is true" do
|
it "adds emails to block list if block_email is true" do
|
||||||
expect {
|
expect {
|
||||||
UserDestroyer.new(@admin).destroy(@user, destroy_opts.merge(block_email: true))
|
UserDestroyer.new(@admin).destroy(@user, destroy_opts.merge(block_email: true))
|
||||||
}.to change { ScreenedEmail.count }.by(1)
|
}.to change { ScreenedEmail.count }.by(2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue