summaryrefslogtreecommitdiffstats
path: root/test/integration/lib
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-10-23 11:00:02 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-10-23 11:00:02 +0000
commitf94711ea8c9998a6a6af74370fdc02c9c25208cb (patch)
treef044eb85f6543787b3786ae9d5eaded412f5915e /test/integration/lib
parent311ca416d75403b5f963bf740910542682f10c36 (diff)
downloadredmine-f94711ea8c9998a6a6af74370fdc02c9c25208cb.tar.gz
redmine-f94711ea8c9998a6a6af74370fdc02c9c25208cb.zip
Option to specify allowed extensions for a file custom field (#6719).
git-svn-id: http://svn.redmine.org/redmine/trunk@15921 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/integration/lib')
-rw-r--r--test/integration/lib/redmine/field_format/attachment_format_test.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/integration/lib/redmine/field_format/attachment_format_test.rb b/test/integration/lib/redmine/field_format/attachment_format_test.rb
index 447ba686f..98aa00548 100644
--- a/test/integration/lib/redmine/field_format/attachment_format_test.rb
+++ b/test/integration/lib/redmine/field_format/attachment_format_test.rb
@@ -153,4 +153,42 @@ class AttachmentFieldFormatTest < Redmine::IntegrationTest
assert_equal attachment.id.to_s, custom_value.value
assert_equal custom_value, attachment.reload.container
end
+
+ def test_create_with_valid_extension
+ @field.extensions_allowed = "txt, log"
+ @field.save!
+
+ attachment = new_record(Attachment) do
+ assert_difference 'Issue.count' do
+ post '/projects/ecookbook/issues', {
+ :issue => {
+ :subject => "Blank",
+ :custom_field_values => {
+ @field.id => {:file => uploaded_test_file("testfile.txt", "text/plain")}
+ }
+ }
+ }
+ assert_response 302
+ end
+ end
+ end
+
+ def test_create_with_invalid_extension_should_fail
+ @field.extensions_allowed = "png, jpeg"
+ @field.save!
+
+ attachment = new_record(Attachment) do
+ assert_no_difference 'Issue.count' do
+ post '/projects/ecookbook/issues', {
+ :issue => {
+ :subject => "Blank",
+ :custom_field_values => {
+ @field.id => {:file => uploaded_test_file("testfile.txt", "text/plain")}
+ }
+ }
+ }
+ assert_response :success
+ end
+ end
+ end
end