Sha256: d4ab9722b3ca4edae8f4f44bb44605235829fcc9564ff225bdecb10bd2608f80

Contents?: true

Size: 1011 Bytes

Versions: 6

Compression:

Stored size: 1011 Bytes

Contents

require 'cms/data_loader'

require File.expand_path(File.join(__FILE__, "..", "..", "..", "test", "mock_file"))
module FileOperations

  # Creates an 'uploaded' file block at a given relative path
  # @param [String] relative_file_path A relative file path (i.e. /test.txt) for the uploaded block.
  def create_file(relative_file_path, text="Test Content")
    # We are creating a temp file with no path, so strip leading slash
    file_name = relative_file_path.gsub(/^\//, "")
    tempfile = Tempfile.new file_name do |f|
      f << text
    end
    tempfile << text
    tempfile.flush
    tempfile.close

    upload_file = Rack::Test::UploadedFile.new(tempfile.path, "text/plain", false)
    Factory(:file_block, :attachment_file => upload_file, :attachment_file_path => file_name)
  end
end

World(FileOperations)

# Make sure the database is completely empty before we start, then go back to cleaning up between transactions.
DatabaseCleaner.clean_with :truncation
DatabaseCleaner.strategy = :transaction

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
browsercms-3.4.2 features/support/debugging.rb
browsercms-3.4.2.rc1 features/support/debugging.rb
browsercms-3.4.1 features/support/debugging.rb
browsercms-3.4.0 features/support/debugging.rb
browsercms-3.4.0.rc2 features/support/debugging.rb
browsercms-3.4.0.rc1 features/support/debugging.rb