aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-09-26 20:29:06 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-09-26 20:29:06 +0000
commit27ecb482c69ced7e8e468fd8f71ec817b4ed2d6f (patch)
tree900655f9c55ac83469c13c653195cc4bc492392e /activerecord/test
parenta5e2f6cd28710e4a81e850a77d5d0833cb1379de (diff)
downloadrails-27ecb482c69ced7e8e468fd8f71ec817b4ed2d6f.tar.gz
rails-27ecb482c69ced7e8e468fd8f71ec817b4ed2d6f.tar.bz2
rails-27ecb482c69ced7e8e468fd8f71ec817b4ed2d6f.zip
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
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/binary_test.rb65
1 files changed, 22 insertions, 43 deletions
diff --git a/activerecord/test/binary_test.rb b/activerecord/test/binary_test.rb
index ba43524264..e3b4e7ea05 100644
--- a/activerecord/test/binary_test.rb
+++ b/activerecord/test/binary_test.rb
@@ -2,53 +2,32 @@ require 'abstract_unit'
require 'fixtures/binary'
class BinaryTest < Test::Unit::TestCase
+ BINARY_FIXTURE_PATH = File.dirname(__FILE__) + '/fixtures/flowers.jpg'
+
def setup
- @data = create_data_fixture
+ Binary.connection.execute 'DELETE FROM binaries'
+ @data = File.read(BINARY_FIXTURE_PATH).freeze
end
-
- def test_load_save
- # 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.
- if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter
- return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)
- end
- # 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
-
- if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter
- return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter)
- end
- bin = Binary.new
- bin.data = @data
+ # 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 bin.data == @data,
- "Assigned data differs from file data"
-
- bin.save
+ assert @data == bin.data, 'Newly assigned data differs from original'
+
+ bin.save
+ assert @data == bin.data, 'Data differs from original after 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 differs from memory version"
-
- assert db_bin.data == File.new(File.dirname(__FILE__)+"/fixtures/associations.png","rb").read,
- "Loaded binary data differs 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
+ db_bin = Binary.find(bin.id)
+ assert @data == db_bin.data, 'Reloaded data differs from original'
+ end
end
-
end