blob: 1e74b023bfd04fa0ee586ec50ad3fc337fcda346 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
require 'abstract_unit'
require 'fixtures/binary'
class BinaryTest < Test::Unit::TestCase
def setup
@data = create_data_fixture
end
def test_load_save
# Without using prepared statements, it makes no sense to test
# BLOB data with DB2, because the length of a statement is
# limited to 32KB.
if ActiveRecord::ConnectionAdapters.const_defined? :DB2Adapter
return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::DB2Adapter)
end
bin = Binary.new
bin.data = @data
assert bin.data == @data,
"Assigned data differs from file data"
bin.save
assert bin.data == @data,
"Assigned data differs from file data after save"
db_bin = Binary.find(bin.id)
assert db_bin.data == bin.data,
"Loaded binary data differes from memory version"
assert db_bin.data == File.new(File.dirname(__FILE__)+"/fixtures/associations.png","rb").read,
"Loaded binary data differes from file version"
end
private
def create_data_fixture
Binary.connection.execute("DELETE FROM binaries")
File.new(File.dirname(__FILE__)+"/fixtures/associations.png","rb").read
end
end
|