Sha256: af23e2750c6fe213701d552500006f242ef5d2a26916a472dd199fc2cf5828ad

Contents?: true

Size: 953 Bytes

Versions: 6

Compression:

Stored size: 953 Bytes

Contents

module Cms

  # Simplified handling for creating files for writing tests around multipart uploads.
  module MockFile
    FILES_DIR = File.dirname(__FILE__) + '/fixtures/multipart'

    # Creates a file to test uploading to a sample file.
    def self.new_file(file_name='foo.jpg', content_type="image/jpeg")
      Rack::Test::UploadedFile.new("#{FILES_DIR}/#{file_name}", content_type, false)
    end
  end

  # For activating logging on the console 
  def self.activate_logging
    ActiveRecord::Base.logger = Logger.new(STDOUT)
  end
end

module Extensions
  module Rack
    module Test
      # Extensions to make Rack::Test::UploadedFile function like ActionDispatch::Http::UploadedFile during unit/functional tests.
      module UploadedFile

        # Attachment relies on this being there
        def tempfile
          @tempfile
        end
      end
    end
  end
end
Rack::Test::UploadedFile.send(:include, Extensions::Rack::Test::UploadedFile)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
browsercms-3.4.2 test/mock_file.rb
browsercms-3.4.2.rc1 test/mock_file.rb
browsercms-3.4.1 test/mock_file.rb
browsercms-3.4.0 test/mock_file.rb
browsercms-3.4.0.rc2 test/mock_file.rb
browsercms-3.4.0.rc1 test/mock_file.rb