Sha256: e86159f8d4a34ed280464a77e6f63aeffc6edd273c4a44583cee149035722a08

Contents?: true

Size: 882 Bytes

Versions: 1

Compression:

Stored size: 882 Bytes

Contents

require 'test_helper'

class FileStringTest < ActiveSupport::TestCase

  setup :create_file

  test 'methods should work properly' do

    # Basic tests

    assert @file.exists?
    assert_equal 11, @file.size
    assert_equal '.txt', @file.extname
    assert_equal ::File.join('', 'uploads', 'files', @file.filename), @file.path
    assert_equal Rails.root.join('public', 'uploads', 'files', @file.filename).to_s, @file.realpath

    # Delete tests

    uploads_path = Rails.root.join('public', 'uploads', 'files', @file.filename).to_s
    @file.delete
    assert !File.exists?(uploads_path)
    assert !@file.exists?

  end

  protected

  def create_file
    filename = 'file.txt'
    FileUtils.cp ::File.join(ActiveSupport::TestCase.fixture_path, filename), Rails.root.join('public', 'uploads', 'files', filename)
    @file = RailsUploads::Types::File.new(filename)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_uploads-0.1.4 test/file_string_test.rb