store_helper.rb 735 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. module ZammadStoreHelper
  3. # Add attachment to Store
  4. #
  5. # @param id [Integer] ID of the owner object
  6. # @param object_name [String] class name of the owner object
  7. # @param filename [String] filename (including path) to file to use as a test.
  8. #
  9. def attach(id:, object_name: 'UploadCache', filename: 'test/data/image/1x1.png')
  10. Store.add(
  11. object: object_name,
  12. o_id: id,
  13. data: File.binread(Rails.root.join(filename)),
  14. filename: Pathname.new(filename).basename,
  15. preferences: {},
  16. created_by_id: 1,
  17. )
  18. end
  19. end
  20. RSpec.configure do |config|
  21. config.include ZammadStoreHelper
  22. end