Module: ActionController::TestProcess

Defined in:
lib/plugins/extension_patches/lib/fixture_loading_extension.rb

Instance Method Summary collapse

Instance Method Details

#fixture_file_upload(path, mime_type = nil) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/plugins/extension_patches/lib/fixture_loading_extension.rb', line 58

def fixture_file_upload(path, mime_type = nil)
  if Test::Unit::TestCase.respond_to?(:fixture_path)
    fixture_path = Test::Unit::TestCase.fixture_path
    if(fixture_path.respond_to? :to_str)
      ActionController::TestUploadedFile.new(
        fixture_path.to_str + path,
        mime_type
      )
    else
      best_path = fixture_path.find { |x| File.exist? (x + path) }
      best_path ||= fixture_path.last
      ActionController::TestUploadedFile.new(
        best_path + path,
        mime_type
      )
    end
  else
    ActionController::TestUploadedFile.new(
      path,
      mime_type
    )
  end
end