Simplify method to calculate document max size
Since we're only doing the convertion from bytes to megabytes in one place, IMHO adding an extra method makes the code harder to read. This way we don't have do include the DocumentsHelper in the specs anymore, reducing the risk of possible method naming collisions.
This commit is contained in:
@@ -8,7 +8,7 @@ module DocumentablesHelper
|
||||
end
|
||||
|
||||
def max_file_size(documentable_class)
|
||||
bytes_to_mega(documentable_class.max_file_size)
|
||||
documentable_class.max_file_size / Numeric::MEGABYTE
|
||||
end
|
||||
|
||||
def accepted_content_types(documentable_class)
|
||||
|
||||
@@ -7,10 +7,6 @@ module DocumentsHelper
|
||||
document.errors[:attachment].join(", ") if document.errors.key?(:attachment)
|
||||
end
|
||||
|
||||
def bytes_to_mega(bytes)
|
||||
bytes / Numeric::MEGABYTE
|
||||
end
|
||||
|
||||
def render_destroy_document_link(builder, document)
|
||||
if !document.persisted? && document.cached_attachment.present?
|
||||
link_to t("documents.form.delete_button"),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
shared_examples "document validations" do |documentable_factory|
|
||||
include DocumentsHelper
|
||||
include DocumentablesHelper
|
||||
|
||||
let!(:document) { build(:document, documentable_factory.to_sym) }
|
||||
|
||||
Reference in New Issue
Block a user