diff options
author | Stan Hu <stanhu@gmail.com> | 2015-03-20 05:11:12 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-04-02 00:04:08 -0700 |
commit | dfd256f29ee817b5ffc563bb554a02d26ae44502 (patch) | |
tree | c28e943c541df30a2a0ab03905bf5d7bbe61b3ba /lib/file_size_validator.rb | |
parent | 16a6ea2d1769f68157976b83bf6da468dd38853d (diff) | |
download | gitlab-ce-dfd256f29ee817b5ffc563bb554a02d26ae44502.tar.gz |
Support configurable attachment size via Application Settings
Fix bug where error messages from Dropzone would not be displayed on the issues page
Closes #1258
Diffstat (limited to 'lib/file_size_validator.rb')
-rw-r--r-- | lib/file_size_validator.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/file_size_validator.rb b/lib/file_size_validator.rb index 42970c1be59..2eae55e534b 100644 --- a/lib/file_size_validator.rb +++ b/lib/file_size_validator.rb @@ -25,8 +25,8 @@ class FileSizeValidator < ActiveModel::EachValidator keys.each do |key| value = options[key] - unless value.is_a?(Integer) && value >= 0 - raise ArgumentError, ":#{key} must be a nonnegative Integer" + unless (value.is_a?(Integer) && value >= 0) || value.is_a?(Symbol) + raise ArgumentError, ":#{key} must be a nonnegative Integer or symbol" end end end @@ -39,6 +39,14 @@ class FileSizeValidator < ActiveModel::EachValidator CHECKS.each do |key, validity_check| next unless check_value = options[key] + check_value = + case check_value + when Integer + check_value + when Symbol + record.send(check_value) + end + value ||= [] if key == :maximum value_size = value.size |