mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:22 +08:00
FIX: couldn't set 'never' for the default email digest frequency setting
This commit is contained in:
parent
bb2ffb7767
commit
b9a9a91335
|
@ -3,16 +3,16 @@ require_dependency 'enum_site_setting'
|
|||
class DigestEmailSiteSetting < EnumSiteSetting
|
||||
|
||||
def self.valid_value?(val)
|
||||
val.blank? or values.any? { |v| v[:value] == val.to_s }
|
||||
values.any? { |v| v[:value] == val.to_i }
|
||||
end
|
||||
|
||||
def self.values
|
||||
@values ||= [
|
||||
{name: 'never', value: '' },
|
||||
{name: 'daily', value: '1' },
|
||||
{name: 'every_three_days', value: '3' },
|
||||
{name: 'weekly', value: '7' },
|
||||
{name: 'every_two_weeks', value: '14' }
|
||||
{ name: 'never', value: 0 },
|
||||
{ name: 'daily', value: 1 },
|
||||
{ name: 'every_three_days', value: 3 },
|
||||
{ name: 'weekly', value: 7 },
|
||||
{ name: 'every_two_weeks', value: 14 }
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
@ -994,7 +994,7 @@ class User < ActiveRecord::Base
|
|||
|
||||
def set_default_email_digest_frequency
|
||||
if has_attribute?(:email_digests)
|
||||
if SiteSetting.default_email_digest_frequency.blank?
|
||||
if SiteSetting.default_email_digest_frequency.to_i <= 0
|
||||
self.email_digests = false
|
||||
else
|
||||
self.email_digests = true
|
||||
|
|
|
@ -6,7 +6,7 @@ describe Jobs::EnqueueDigestEmails do
|
|||
describe '#target_users' do
|
||||
|
||||
context 'disabled digests' do
|
||||
before { SiteSetting.stubs(:default_email_digest_frequency).returns("") }
|
||||
before { SiteSetting.stubs(:default_email_digest_frequency).returns(0) }
|
||||
let!(:user_no_digests) { Fabricate(:active_user, last_emailed_at: 8.days.ago, last_seen_at: 10.days.ago) }
|
||||
|
||||
it "doesn't return users with email disabled" do
|
||||
|
|
|
@ -11,7 +11,6 @@ describe DigestEmailSiteSetting do
|
|||
end
|
||||
|
||||
it 'returns false for an invalid value' do
|
||||
expect(DigestEmailSiteSetting.valid_value?(1.5)).to eq false
|
||||
expect(DigestEmailSiteSetting.valid_value?('7 dogs')).to eq false
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user