Sha256: 57a0632f26cb13d1d8f66cbc73264f99ec59a5ac14bc497bfa3e53b0b70c0897

Contents?: true

Size: 1.59 KB

Versions: 2

Compression:

Stored size: 1.59 KB

Contents

# Configure Rails Environment
ENV['RAILS_ENV'] = 'test'

require File.expand_path('../dummy/config/environment.rb',  __FILE__)
require 'rails/test_help'

Rails.backtrace_cleaner.remove_silencers!

# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

# Load fixtures from the engine
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
  ActiveSupport::TestCase.fixture_path = File.expand_path('../fixtures', __FILE__)
end

# Load database
config = YAML::load(File.read(File.expand_path('../dummy/config/database.yml', __FILE__)))
config['test']['adapter'] = 'jdbcsqlite3' if RUBY_PLATFORM == 'java'
ActiveRecord::Base.establish_connection(config['test'])
load(File.expand_path('../dummy/db/schema.rb', __FILE__))

# Addons

class ActiveSupport::TestCase
  include ActionDispatch::TestProcess

  def load_s3
    require 'aws-sdk' unless defined?(AWS)
    @storage_type = Rails.application.config.uploads.storage
    Rails.application.config.uploads.storage = :s3
    RailsUploads::Storages::S3.config = YAML.load_file(Rails.root.join('config', 's3.yml')) if RailsUploads::Storages::S3.config.blank?
    self.class.teardown { Rails.application.config.uploads.storage = @storage_type }
  end

  def fixture_file_upload_s3(fixture, type, path, tmp=true)
    upload = fixture_file_upload(fixture, type)
    storage = RailsUploads::Storages::S3.new(tmp)
    storage.store(upload, path)
  end

  def assert_object_s3(url)
    assert_equal '200', Net::HTTP.get_response(url).code
  end

  def assert_not_object_s3(url)
    assert_equal '403', Net::HTTP.get_response(url).code
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_uploads-0.2.1 test/test_helper.rb
rails_uploads-0.2.0 test/test_helper.rb