1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

remove leftover firebird adapter tests.

This commit is contained in:
Yves Senn 2013-11-26 11:05:37 +01:00
parent 6eba8d27e6
commit e161aeab17
3 changed files with 0 additions and 148 deletions

View file

@ -1,8 +0,0 @@
require "cases/helper"
class FirebirdConnectionTest < ActiveRecord::TestCase
def test_charset_properly_set
fb_conn = ActiveRecord::Base.connection.instance_variable_get(:@connection)
assert_equal 'UTF8', fb_conn.database.character_set
end
end

View file

@ -1,16 +0,0 @@
require "cases/helper"
require 'models/default'
class DefaultTest < ActiveRecord::TestCase
def test_default_timestamp
default = Default.new
assert_instance_of(Time, default.default_timestamp)
assert_equal(:datetime, default.column_for_attribute(:default_timestamp).type)
# Variance should be small; increase if required -- e.g., if test db is on
# remote host and clocks aren't synchronized.
t1 = Time.new
accepted_variance = 1.0
assert_in_delta(t1.to_f, default.default_timestamp.to_f, accepted_variance)
end
end

View file

@ -1,124 +0,0 @@
require "cases/helper"
require 'models/course'
class FirebirdMigrationTest < ActiveRecord::TestCase
self.use_transactional_fixtures = false
def setup
# using Course connection for tests -- need a db that doesn't already have a BOOLEAN domain
@connection = Course.connection
@fireruby_connection = @connection.instance_variable_get(:@connection)
end
def teardown
@connection.drop_table :foo rescue nil
@connection.execute("DROP DOMAIN D_BOOLEAN") rescue nil
end
def test_create_table_with_custom_sequence_name
assert_nothing_raised do
@connection.create_table(:foo, :sequence => 'foo_custom_seq') do |f|
f.column :bar, :string
end
end
assert !sequence_exists?('foo_seq')
assert sequence_exists?('foo_custom_seq')
assert_nothing_raised { @connection.drop_table(:foo) }
assert !sequence_exists?('foo_custom_seq')
ensure
FireRuby::Generator.new('foo_custom_seq', @fireruby_connection).drop rescue nil
end
def test_create_table_without_sequence
assert_nothing_raised do
@connection.create_table(:foo, :sequence => false) do |f|
f.column :bar, :string
end
end
assert !sequence_exists?('foo_seq')
assert_nothing_raised { @connection.drop_table :foo }
assert_nothing_raised do
@connection.create_table(:foo, :id => false) do |f|
f.column :bar, :string
end
end
assert !sequence_exists?('foo_seq')
assert_nothing_raised { @connection.drop_table :foo }
end
def test_create_table_with_boolean_column
assert !boolean_domain_exists?
assert_nothing_raised do
@connection.create_table :foo do |f|
f.column :bar, :string
f.column :baz, :boolean
end
end
assert boolean_domain_exists?
end
def test_add_boolean_column
assert !boolean_domain_exists?
@connection.create_table :foo do |f|
f.column :bar, :string
end
assert_nothing_raised { @connection.add_column :foo, :baz, :boolean }
assert boolean_domain_exists?
assert_equal :boolean, @connection.columns(:foo).find { |c| c.name == "baz" }.type
end
def test_change_column_to_boolean
assert !boolean_domain_exists?
# Manually create table with a SMALLINT column, which can be changed to a BOOLEAN
@connection.execute "CREATE TABLE foo (bar SMALLINT)"
assert_equal :integer, @connection.columns(:foo).find { |c| c.name == "bar" }.type
assert_nothing_raised { @connection.change_column :foo, :bar, :boolean }
assert boolean_domain_exists?
assert_equal :boolean, @connection.columns(:foo).find { |c| c.name == "bar" }.type
end
def test_rename_table_with_data_and_index
@connection.create_table :foo do |f|
f.column :baz, :string, :limit => 50
end
100.times { |i| @connection.execute "INSERT INTO foo VALUES (GEN_ID(foo_seq, 1), 'record #{i+1}')" }
@connection.add_index :foo, :baz
assert_nothing_raised { @connection.rename_table :foo, :bar }
assert !@connection.tables.include?("foo")
assert @connection.tables.include?("bar")
assert_equal "index_bar_on_baz", @connection.indexes("bar").first.name
assert_equal 100, FireRuby::Generator.new("bar_seq", @fireruby_connection).last
assert_equal 100, @connection.select_one("SELECT COUNT(*) FROM bar")["count"]
ensure
@connection.drop_table :bar rescue nil
end
def test_renaming_table_with_fk_constraint_raises_error
@connection.create_table :parent do |p|
p.column :name, :string
end
@connection.create_table :child do |c|
c.column :parent_id, :integer
end
@connection.execute "ALTER TABLE child ADD CONSTRAINT fk_child_parent FOREIGN KEY(parent_id) REFERENCES parent(id)"
assert_raise(ActiveRecord::ActiveRecordError) { @connection.rename_table :child, :descendant }
ensure
@connection.drop_table :child rescue nil
@connection.drop_table :descendant rescue nil
@connection.drop_table :parent rescue nil
end
private
def boolean_domain_exists?
!@connection.select_one("SELECT 1 FROM rdb$fields WHERE rdb$field_name = 'D_BOOLEAN'").nil?
end
def sequence_exists?(sequence_name)
FireRuby::Generator.exists?(sequence_name, @fireruby_connection)
end
end