FIX: 'reply by email addresses' site settings should allow email addresses without a 'reply_key' when 'find related post with key' is disabled
This commit is contained in:
parent
334ed74346
commit
6a78669ca3
|
@ -705,6 +705,7 @@ email:
|
||||||
validator: "ReplyByEmailEnabledValidator"
|
validator: "ReplyByEmailEnabledValidator"
|
||||||
reply_by_email_address:
|
reply_by_email_address:
|
||||||
default: ''
|
default: ''
|
||||||
|
validator: "ReplyByEmailAddressValidator"
|
||||||
alternative_reply_by_email_addresses:
|
alternative_reply_by_email_addresses:
|
||||||
default: ''
|
default: ''
|
||||||
validator: "AlternativeReplyByEmailAddressesValidator"
|
validator: "AlternativeReplyByEmailAddressesValidator"
|
||||||
|
|
|
@ -4,11 +4,14 @@ class ReplyByEmailAddressValidator
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_value?(val)
|
def valid_value?(val)
|
||||||
return true if val.blank?
|
return true if val.blank?
|
||||||
|
return false if val["@"].nil?
|
||||||
|
|
||||||
!!val["@"] &&
|
if SiteSetting.find_related_post_with_key
|
||||||
!!val["%{reply_key}"] &&
|
!!val["%{reply_key}"] && val.sub(/\+?%{reply_key}/, "") != SiteSetting.notification_email
|
||||||
val.gsub(/\+?%{reply_key}/, "") != SiteSetting.notification_email
|
else
|
||||||
|
val != SiteSetting.notification_email
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_message
|
def error_message
|
||||||
|
|
|
@ -18,6 +18,11 @@ describe ReplyByEmailAddressValidator do
|
||||||
expect(validator.valid_value?('foo@bar.com')).to eq(false)
|
expect(validator.valid_value?('foo@bar.com')).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns true if value does not contain '%{reply_key}' but 'find_related_post_with_key' is also disabled" do
|
||||||
|
SiteSetting.expects(:find_related_post_with_key).returns(false)
|
||||||
|
expect(validator.valid_value?('foo@bar.com')).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
it "returns false if value is the same as SiteSetting.notification_email" do
|
it "returns false if value is the same as SiteSetting.notification_email" do
|
||||||
SiteSetting.expects(:notification_email).returns("foo@bar.com")
|
SiteSetting.expects(:notification_email).returns("foo@bar.com")
|
||||||
expect(validator.valid_value?('foo+%{reply_key}@bar.com')).to eq(false)
|
expect(validator.valid_value?('foo+%{reply_key}@bar.com')).to eq(false)
|
||||||
|
|
Loading…
Reference in New Issue