mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:16:41 +08:00
FIX: Digest frequency issue on user creation
If `default email digest frequency` was set to "Never", users would get a `digest_after_minutes` set to `nil` which triggered this error in the logs if/when the site eventually changed that setting and enabled digests: ``` NoMethodError (undefined method `>=' for nil:NilClass) /var/www/discourse/app/mailers/user_notifications.rb:227:in `digest' ```
This commit is contained in:
parent
a95826f60c
commit
fa6aa7f627
|
@ -224,7 +224,7 @@ class UserNotifications < ActionMailer::Base
|
|||
@counts << { label_key: 'user_notifications.digest.liked_received', value: value, href: "#{Discourse.base_url}/my/notifications" } if value > 0
|
||||
end
|
||||
|
||||
if @counts.size < 3 && user.user_option.digest_after_minutes >= 1440
|
||||
if @counts.size < 3 && user.user_option.digest_after_minutes.to_i >= 1440
|
||||
value = summary_new_users_count(min_date)
|
||||
@counts << { label_key: 'user_notifications.digest.new_users', value: value, href: "#{Discourse.base_url}/about" } if value > 0
|
||||
end
|
||||
|
|
|
@ -68,9 +68,10 @@ class UserOption < ActiveRecord::Base
|
|||
self.email_digests = false
|
||||
else
|
||||
self.email_digests = true
|
||||
self.digest_after_minutes ||= SiteSetting.default_email_digest_frequency.to_i
|
||||
end
|
||||
|
||||
self.digest_after_minutes ||= SiteSetting.default_email_digest_frequency.to_i
|
||||
|
||||
self.include_tl0_in_digests = SiteSetting.default_include_tl0_in_digests
|
||||
|
||||
self.text_size = SiteSetting.default_text_size
|
||||
|
|
|
@ -33,6 +33,20 @@ describe UserOption do
|
|||
it "should not hide the profile and presence by default" do
|
||||
expect(user.user_option.hide_profile_and_presence).to eq(false)
|
||||
end
|
||||
|
||||
it "should correctly set digest frequency" do
|
||||
SiteSetting.default_email_digest_frequency = 1440
|
||||
user = Fabricate(:user)
|
||||
expect(user.user_option.email_digests).to eq(true)
|
||||
expect(user.user_option.digest_after_minutes).to eq(1440)
|
||||
end
|
||||
|
||||
it "should correctly set digest frequency when disabled" do
|
||||
SiteSetting.default_email_digest_frequency = 0
|
||||
user = Fabricate(:user)
|
||||
expect(user.user_option.email_digests).to eq(false)
|
||||
expect(user.user_option.digest_after_minutes).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
describe "site settings" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user