aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-01-11 17:04:24 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-01-13 14:33:54 -0800
commit5c8da16a20d43171fd17ebcdca7a57ec7761859e (patch)
tree5f27186565fcc6e60abebe013d720aac5f665914 /activerecord/test/cases
parentee4e24244b818a16eaa16c7b2a83e40d70b8d6ea (diff)
downloadrails-5c8da16a20d43171fd17ebcdca7a57ec7761859e.tar.gz
rails-5c8da16a20d43171fd17ebcdca7a57ec7761859e.tar.bz2
rails-5c8da16a20d43171fd17ebcdca7a57ec7761859e.zip
decoupling more tests from AR::Base
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/migration/change_schema_test.rb45
-rw-r--r--activerecord/test/cases/migration_test.rb24
2 files changed, 45 insertions, 24 deletions
diff --git a/activerecord/test/cases/migration/change_schema_test.rb b/activerecord/test/cases/migration/change_schema_test.rb
index c877f3dd95..8d4c1272a4 100644
--- a/activerecord/test/cases/migration/change_schema_test.rb
+++ b/activerecord/test/cases/migration/change_schema_test.rb
@@ -17,6 +17,51 @@ module ActiveRecord
ActiveRecord::Base.primary_key_prefix_type = nil
end
+ def test_remove_nonexistent_index
+ skip "not supported on openbase" if current_adapter?(:OpenBaseAdapter)
+
+ connection.create_table table_name do |t|
+ t.column :foo, :string, :limit => 100
+ t.column :bar, :string, :limit => 100
+ end
+
+ # we do this by name, so OpenBase is a wash as noted above
+ assert_raise(ArgumentError) { connection.remove_index(table_name, "no_such_index") }
+ end
+
+ def test_add_index_length_limit
+ connection.create_table table_name do |t|
+ t.column :foo, :string, :limit => 100
+ t.column :bar, :string, :limit => 100
+ end
+
+ good_index_name = 'x' * connection.index_name_length
+ too_long_index_name = good_index_name + 'x'
+
+ assert_raises(ArgumentError) {
+ connection.add_index(table_name, "foo", :name => too_long_index_name)
+ }
+
+ refute connection.index_name_exists?(table_name, too_long_index_name, false)
+ connection.add_index(table_name, "foo", :name => good_index_name)
+
+ assert connection.index_name_exists?(table_name, good_index_name, false)
+ connection.remove_index(table_name, :name => good_index_name)
+ end
+
+ def test_index_symbol_names
+ connection.create_table :testings do |t|
+ t.column :foo, :string, :limit => 100
+ t.column :bar, :string, :limit => 100
+ end
+
+ connection.add_index table_name, :foo, :name => :symbol_index_name
+ assert connection.index_exists?(table_name, :foo, :name => :symbol_index_name)
+
+ connection.remove_index table_name, :name => :symbol_index_name
+ refute connection.index_exists?(table_name, :foo, :name => :symbol_index_name)
+ end
+
def test_index_exists
connection.create_table :testings do |t|
t.column :foo, :string, :limit => 100
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 3e1d03b6ab..0519826ae0 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -62,30 +62,6 @@ class MigrationTest < ActiveRecord::TestCase
Person.reset_column_information
end
- def test_index_symbol_names
- assert_nothing_raised { Person.connection.add_index :people, :primary_contact_id, :name => :symbol_index_name }
- assert Person.connection.index_exists?(:people, :primary_contact_id, :name => :symbol_index_name)
- assert_nothing_raised { Person.connection.remove_index :people, :name => :symbol_index_name }
- assert !Person.connection.index_exists?(:people, :primary_contact_id, :name => :symbol_index_name)
- end
-
- def test_add_index_length_limit
- good_index_name = 'x' * Person.connection.index_name_length
- too_long_index_name = good_index_name + 'x'
- assert_raise(ArgumentError) { Person.connection.add_index("people", "first_name", :name => too_long_index_name) }
- assert !Person.connection.index_name_exists?("people", too_long_index_name, false)
- assert_nothing_raised { Person.connection.add_index("people", "first_name", :name => good_index_name) }
- assert Person.connection.index_name_exists?("people", good_index_name, false)
- Person.connection.remove_index("people", :name => good_index_name)
- end
-
- def test_remove_nonexistent_index
- skip "not supported on openbase" if current_adapter?(:OpenBaseAdapter)
-
- # we do this by name, so OpenBase is a wash as noted above
- assert_raise(ArgumentError) { Person.connection.remove_index("people", "no_such_index") }
- end
-
def test_rename_index
skip "not supported on openbase" if current_adapter?(:OpenBaseAdapter)