Make base implementation of target-file target_basename to use and cache the more expressive generate_file_name method indicating a temporary nature of the result

This commit is contained in:
2018-05-16 14:13:30 -03:00
parent 58f9c95f4e
commit c0a951c5f3
3 changed files with 11 additions and 4 deletions
+1
View File
@@ -19,6 +19,7 @@ group :development, :test do
gem 'semantic-ui-sass'
gem 'foundation-rails', '~> 5.4'
gem "select2-rails"
gem 'puma'
#gem 'carrierwave'
#gem 'fog-aws'
gem 'uuidtools'
+9 -3
View File
@@ -66,10 +66,16 @@ module Dunlop::TargetFileModel
gzip_file? ? result + ".gz" : result
end
# TODO: consider builder.file_name if builder option is used by default.
# This will synchronize file names between regular controller downloads and
# target file creation.
# Target file basename used on creation to deliver the desired file_name.
# On actul persisted records this method cannot be used for naming. Then
# @record.original_file&.original_filename or @record.original_file_file_name
# should be used
def target_basename
@target_basename ||= generate_file_name
end
# This method should contain the dynamically generated filename, could include precise timestamp, that differs per inquiry. Should be cached on instance creation
def generate_file_name
"#{self.class.name.demodulize.underscore}-#{date_number}.csv"
end
+1 -1
View File
@@ -37,7 +37,7 @@ ActiveRecord::Migration.maintain_test_schema!
Capybara.javascript_driver = :poltergeist
Capybara::Screenshot.webkit_options = { width: 1024, height: 768 }
Capybara.save_and_open_page_path = Rails.root.join('tmp/screenshots')
#Capybara.save_and_open_page_path = Rails.root.join('tmp/screenshots')
RSpec::Support::ObjectFormatter.default_instance.max_formatted_output_length = 10_000 # do not trash string like: expected: "abc .... def"