FIX: automatically disable digests when enabling mailing list mode
This commit is contained in:
parent
671e230490
commit
6edd3c347c
|
@ -70,14 +70,13 @@ class UserUpdater
|
||||||
TagUser.batch_set(user, level, attributes[attribute])
|
TagUser.batch_set(user, level, attributes[attribute])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
save_options = false
|
save_options = false
|
||||||
|
|
||||||
OPTION_ATTR.each do |attribute|
|
OPTION_ATTR.each do |attribute|
|
||||||
if attributes.key?(attribute)
|
if attributes.key?(attribute)
|
||||||
save_options = true
|
save_options = true
|
||||||
|
|
||||||
if [true,false].include?(user.user_option.send(attribute))
|
if [true, false].include?(user.user_option.send(attribute))
|
||||||
val = attributes[attribute].to_s == 'true'
|
val = attributes[attribute].to_s == 'true'
|
||||||
user.user_option.send("#{attribute}=", val)
|
user.user_option.send("#{attribute}=", val)
|
||||||
else
|
else
|
||||||
|
@ -86,6 +85,9 @@ class UserUpdater
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# automatically disable digests when mailing_list_mode is enabled
|
||||||
|
user.user_option.email_digests = false if user.user_option.mailing_list_mode
|
||||||
|
|
||||||
fields = attributes[:custom_fields]
|
fields = attributes[:custom_fields]
|
||||||
if fields.present?
|
if fields.present?
|
||||||
user.custom_fields = user.custom_fields.merge(fields)
|
user.custom_fields = user.custom_fields.merge(fields)
|
||||||
|
|
|
@ -91,6 +91,19 @@ describe UserUpdater do
|
||||||
expect(user.date_of_birth).to eq(date_of_birth.to_date)
|
expect(user.date_of_birth).to eq(date_of_birth.to_date)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "disables email_digests when enabling mailing_list_mode" do
|
||||||
|
user = Fabricate(:user)
|
||||||
|
updater = UserUpdater.new(acting_user, user)
|
||||||
|
|
||||||
|
val = updater.update(mailing_list_mode: true, email_digests: true)
|
||||||
|
expect(val).to be_truthy
|
||||||
|
|
||||||
|
user.reload
|
||||||
|
|
||||||
|
expect(user.user_option.email_digests).to eq false
|
||||||
|
expect(user.user_option.mailing_list_mode).to eq true
|
||||||
|
end
|
||||||
|
|
||||||
context 'when sso overrides bio' do
|
context 'when sso overrides bio' do
|
||||||
it 'does not change bio' do
|
it 'does not change bio' do
|
||||||
SiteSetting.enable_sso = true
|
SiteSetting.enable_sso = true
|
||||||
|
|
Loading…
Reference in New Issue