Project

General

Profile

Feature #7056 » human-readable-file-size.patch

Go MAEDA, 2020-03-22 04:52

View differences:

app/controllers/attachments_controller.rb
18 18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 19

  
20 20
class AttachmentsController < ApplicationController
21
  include ActionView::Helpers::NumberHelper
22

  
21 23
  before_action :find_attachment, :only => [:show, :download, :thumbnail, :update, :destroy]
22 24
  before_action :find_container, :only => [:edit_all, :update_all, :download_all]
23 25
  before_action :find_downloadable_attachments, :only => :download_all
......
239 241
    bulk_download_max_size = Setting.bulk_download_max_size.to_i.kilobytes
240 242
    if @attachments.sum(&:filesize) > bulk_download_max_size
241 243
      flash[:error] = l(:error_bulk_download_size_too_big,
242
                        :max_size => bulk_download_max_size.to_i.kilobytes)
244
                        :max_size => number_to_human_size(bulk_download_max_size.to_i))
243 245
      redirect_to back_url
244 246
      return
245 247
    end
test/functional/attachments_controller_test.rb
617 617
          :back_url => '/issues/2'
618 618
      }
619 619
      assert_redirected_to '/issues/2'
620
      assert_equal flash[:error], 'These attachments cannot be bulk downloaded because the total file size exceeds the maximum allowed size (0)'
620
      assert_equal flash[:error], 'These attachments cannot be bulk downloaded because the total file size exceeds the maximum allowed size (0 Bytes)'
621 621
    end
622 622
  end
623 623

  
(14-14/22)