1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/binary_test.rb
Jeremy Kemper 27ecb482c6 r3591@asus: jeremy | 2005-09-26 17:01:30 -0700
Simplify binary unit test.  Use flowers.jpg instead of associations.png


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2348 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-09-26 20:29:06 +00:00

33 lines
1 KiB
Ruby

require 'abstract_unit'
require 'fixtures/binary'
class BinaryTest < Test::Unit::TestCase
BINARY_FIXTURE_PATH = File.dirname(__FILE__) + '/fixtures/flowers.jpg'
def setup
Binary.connection.execute 'DELETE FROM binaries'
@data = File.read(BINARY_FIXTURE_PATH).freeze
end
# Without using prepared statements, it makes no sense to test
# BLOB data with SQL Server, because the length of a statement is
# limited to 8KB.
#
# Without using prepared statements, it makes no sense to test
# BLOB data with DB2, because the length of a statement is
# limited to 32KB.
unless %w(SQLServer DB2 OCI).include? ActiveRecord::Base.connection.adapter_name
def test_load_save
bin = Binary.new
bin.data = @data
assert @data == bin.data, 'Newly assigned data differs from original'
bin.save
assert @data == bin.data, 'Data differs from original after save'
db_bin = Binary.find(bin.id)
assert @data == db_bin.data, 'Reloaded data differs from original'
end
end
end