Sha256: 074fa5459b93ef9fb852d2bfcf46ea96bbbeb3d70efd5c7cb6da553bdd4befb3

Contents?: true

Size: 898 Bytes

Versions: 1

Compression:

Stored size: 898 Bytes

Contents

require 'test_helper'

class FileUploadTest < ActiveSupport::TestCase
  include ActionDispatch::TestProcess

  setup :create_file

  test "methods should work properly" do
    
    # Basic tests
    
    assert @file.exists?
    assert_equal 58841, @file.size
    assert_equal '.jpg', @file.extname
    assert_equal ::File.join('', 'uploads', 'files', @file.filename), @file.path

    # Delete test
    
    @file.delete
    assert @file.exists?

    # Store and delete tests
    
    @file.store
    uploads_path = Rails.root.join('tmp', 'uploads', 'files', @file.filename).to_s
    assert ::File.exists?(uploads_path)
    assert_equal uploads_path, @file.realpath
    
    @file.delete
    assert !::File.exists?(uploads_path)
    assert !@file.exists?
  
  end

  protected

  def create_file
    @file = RailsUploads::Types::File.new(fixture_file_upload('/image.jpg', 'image/jpeg'))
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_uploads-0.1.5 test/file_upload_test.rb