aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-27 16:53:07 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-27 16:53:07 -0300
commit9d21ef9388cd16a9c1e8d356a1ba15895451c873 (patch)
tree1c4207b2393d0dae616ff70048e492ff6be0fb79 /activerecord
parente84799d9c6e06ca65b798f55458683721a03f6f8 (diff)
downloadrails-9d21ef9388cd16a9c1e8d356a1ba15895451c873.tar.gz
rails-9d21ef9388cd16a9c1e8d356a1ba15895451c873.tar.bz2
rails-9d21ef9388cd16a9c1e8d356a1ba15895451c873.zip
Improve tests to use add_foreign_key DSL
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb29
1 files changed, 11 insertions, 18 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb
index cc5ccdf835..1a0f447ec2 100644
--- a/activerecord/test/cases/associations/belongs_to_associations_test.rb
+++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -938,28 +938,21 @@ end
unless current_adapter?(:MysqlAdapter, :Mysql2Adapter)
class BelongsToWithForeignKeyTest < ActiveRecord::TestCase
- def setup
- ActiveRecord::Schema.define do
- create_table :author_addresses do |t|
- end
+ setup do
+ @connection = ActiveRecord::Base.connection
+ @connection.create_table :author_addresses, force: true
- exec_query <<-eos
- create table authors(
- id int,
- author_address_id int,
- name varchar(255),
- PRIMARY KEY (id),
- FOREIGN KEY (author_address_id) REFERENCES author_addresses(id)
- );
- eos
+ @connection.create_table :authors, force: true do |t|
+ t.string :name
+ t.references :author_address
end
+
+ @connection.add_foreign_key :authors, :author_address
end
- def teardown
- ActiveRecord::Schema.define do
- drop_table :authors, if_exists: true
- drop_table :author_addresses, if_exists: true
- end
+ teardown do
+ @connection.drop_table :authors, if_exists: true
+ @connection.drop_table :author_addresses, if_exists: true
end
def test_destroy_linked_models