-
Notifications
You must be signed in to change notification settings - Fork 992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #24057 Email subject prefix accepts long strings #5742
Fixes #24057 Email subject prefix accepts long strings #5742
Conversation
Do not merge! This patch has not been tested yet. Can an existing organization member please verify this patch? |
2 similar comments
Do not merge! This patch has not been tested yet. Can an existing organization member please verify this patch? |
Do not merge! This patch has not been tested yet. Can an existing organization member please verify this patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apuntamb: Thanks. Please see my comments inline.
@@ -22,6 +22,11 @@ class EmailSettingTest < ActiveSupport::TestCase | |||
assert_equal({"address" => "string@example.com", "authentication" => 'plain'}, Setting::Email.delivery_settings) | |||
end | |||
|
|||
test 'value of email_subject_prefix should not be more than 255 characters' do | |||
Setting[:email_subject_prefix] = 'p' * 255 | |||
assert_not Setting::Email.new.valid? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a nice helper for this: refute_valid
app/models/setting.rb
Outdated
@@ -50,6 +50,7 @@ def validate(record) | |||
validates_with ValueValidator, :if => Proc.new {|s| s.respond_to?("validate_#{s.name}") } | |||
validates :value, :array_hostnames => true, :if => Proc.new { |s| ARRAY_HOSTNAMES.include? s.name } | |||
validates :value, :email => true, :if => Proc.new { |s| EMAIL_ATTRS.include? s.name } | |||
validates :value, :length => {:maximum => 255}, :if => Proc.new { |s| s.name == "email_subject_prefix" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we safely move this to app/models/setting/email.rb
?
7a128ab
to
6493d07
Compare
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine. More guidelines are available in Coding Standards or on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
6493d07
to
4153848
Compare
@@ -22,6 +22,11 @@ class EmailSettingTest < ActiveSupport::TestCase | |||
assert_equal({"address" => "string@example.com", "authentication" => 'plain'}, Setting::Email.delivery_settings) | |||
end | |||
|
|||
test 'value of email_subject_prefix should not be more than 255 characters' do | |||
Setting[:email_subject_prefix] = 'p' * 255 | |||
refute_valid Setting::Email.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the test now tests the wrong thing. This is probably invalid because no name is set. Can you please check if the setting you create above is not valid?
4153848
to
38dfc53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test looks like it was fixed, thanks @apuntamb @timogoebel
fixed test - Setting::Email.new is not valid with a subject of 256 chars
This patch broke develop tests:
|
@dLobatog the reason for that was that Jenkins did not run Foreman tests at all... |
Thanks @lzap for the quick fix. |
No description provided.