Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/branches/2-1-caching/activerecord/test/binary_test.rb

Revision 8185, 1.0 kB (checked in by bitsweat, 1 year ago)

PostgreSQL: correct binary escaping. References #8049, closes #10176 [jbasdf, tmacedo]

Line 
1 require 'abstract_unit'
2
3 # Without using prepared statements, it makes no sense to test
4 # BLOB data with SQL Server, because the length of a statement is
5 # limited to 8KB.
6 #
7 # Without using prepared statements, it makes no sense to test
8 # BLOB data with DB2 or Firebird, because the length of a statement
9 # is limited to 32KB.
10 unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :DB2Adapter, :FirebirdAdapter)
11   require 'fixtures/binary'
12
13   class BinaryTest < Test::Unit::TestCase
14     FIXTURES = %w(flowers.jpg example.log)
15
16     def test_load_save
17       Binary.delete_all
18
19       FIXTURES.each do |filename|
20         data = File.read("#{File.dirname(__FILE__)}/fixtures/#{filename}").freeze
21
22         bin = Binary.new(:data => data)
23         assert_equal data, bin.data, 'Newly assigned data differs from original'
24
25         bin.save!
26         assert_equal data, bin.data, 'Data differs from original after save'
27
28         assert_equal data, bin.reload.data, 'Reloaded data differs from original'
29       end
30     end
31   end
32 end
Note: See TracBrowser for help on using the browser.