FEATURE: new 'manual_polling_enabled' site setting

This commit is contained in:
Régis Hanol 2016-03-16 22:28:01 +01:00
parent 84d234a98a
commit 20ce7f29e0
5 changed files with 14 additions and 7 deletions

View file

@ -105,6 +105,10 @@ class SiteSetting < ActiveRecord::Base
nil
end
def self.email_polling_enabled?
SiteSetting.manual_polling_enabled? || SiteSetting.pop3_polling_enabled?
end
end
# == Schema Information

View file

@ -1158,6 +1158,7 @@ en:
delete_email_logs_after_days: "Delete email logs after (N) days. 0 to keep indefinitely"
manual_polling_enabled: "Push emails using the API for email replies."
pop3_polling_enabled: "Poll via POP3 for email replies."
pop3_polling_ssl: "Use SSL while connecting to the POP3 server. (Recommended)"
pop3_polling_period_mins: "The period in minutes between checking the POP3 account for email. NOTE: requires restart."
@ -1310,7 +1311,7 @@ en:
pop3_polling_password_is_empty: "You must set a 'pop3 polling password' before enabling POP3 polling."
pop3_polling_authentication_failed: "POP3 authentication failed. Please verify your pop3 credentials."
reply_by_email_address_is_empty: "You must set a 'reply by email address' before enabling reply by email."
pop3_polling_disabled: "You must first enabled POP3 polling before enabling reply by email."
email_polling_disabled: "You must enable either manual or POP3 polling before enabling reply by email."
user_locale_not_enabled: "You must first enable 'allow user locale' before enabling this setting."
notification_types:

View file

@ -525,6 +525,8 @@ email:
reply_by_email_address:
default: ''
validator: "ReplyByEmailAddressValidator"
manual_polling_enabled:
default: false
pop3_polling_enabled:
default: false
validator: "POP3PollingEnabledSettingValidator"

View file

@ -9,14 +9,14 @@ class ReplyByEmailEnabledValidator
return true if val == "f"
# ensure reply_by_email_address is configured && polling is working
SiteSetting.reply_by_email_address.present? &&
SiteSetting.pop3_polling_enabled?
SiteSetting.email_polling_enabled?
end
def error_message
if SiteSetting.reply_by_email_address.blank?
I18n.t("site_settings.errors.reply_by_email_address_is_empty")
else
I18n.t("site_settings.errors.pop3_polling_disabled")
I18n.t("site_settings.errors.email_polling_disabled")
end
end

View file

@ -14,15 +14,15 @@ describe ReplyByEmailEnabledValidator do
expect(validator.valid_value?("t")).to eq(false)
end
it "returns false if POP3 polling is disabled" do
it "returns false if email polling is disabled" do
SiteSetting.expects(:reply_by_email_address).returns("foo.%{reply_key}+42@bar.com")
SiteSetting.expects(:pop3_polling_enabled).returns(false)
SiteSetting.expects(:email_polling_enabled?).returns(false)
expect(validator.valid_value?("t")).to eq(false)
end
it "returns true when POP3 polling is enabled and the reply_by_email_address is configured" do
it "returns true when email polling is enabled and the reply_by_email_address is configured" do
SiteSetting.expects(:reply_by_email_address).returns("foo.%{reply_key}+42@bar.com")
SiteSetting.expects(:pop3_polling_enabled).returns(true)
SiteSetting.expects(:email_polling_enabled?).returns(true)
expect(validator.valid_value?("t")).to eq(true)
end