mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 17:53:44 +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
|
class DigestEmailSiteSetting < EnumSiteSetting
|
||||||
|
|
||||||
def self.valid_value?(val)
|
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
|
end
|
||||||
|
|
||||||
def self.values
|
def self.values
|
||||||
@values ||= [
|
@values ||= [
|
||||||
{name: 'never', value: '' },
|
{ name: 'never', value: 0 },
|
||||||
{name: 'daily', value: '1' },
|
{ name: 'daily', value: 1 },
|
||||||
{name: 'every_three_days', value: '3' },
|
{ name: 'every_three_days', value: 3 },
|
||||||
{name: 'weekly', value: '7' },
|
{ name: 'weekly', value: 7 },
|
||||||
{name: 'every_two_weeks', value: '14' }
|
{ name: 'every_two_weeks', value: 14 }
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -994,7 +994,7 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
def set_default_email_digest_frequency
|
def set_default_email_digest_frequency
|
||||||
if has_attribute?(:email_digests)
|
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
|
self.email_digests = false
|
||||||
else
|
else
|
||||||
self.email_digests = true
|
self.email_digests = true
|
||||||
|
|
|
@ -6,7 +6,7 @@ describe Jobs::EnqueueDigestEmails do
|
||||||
describe '#target_users' do
|
describe '#target_users' do
|
||||||
|
|
||||||
context 'disabled digests' 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) }
|
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
|
it "doesn't return users with email disabled" do
|
||||||
|
|
|
@ -11,7 +11,6 @@ describe DigestEmailSiteSetting do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false for an invalid value' do
|
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
|
expect(DigestEmailSiteSetting.valid_value?('7 dogs')).to eq false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user