mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix the test defining the models in the right place
This commit is contained in:
parent
989cccdc3e
commit
57c7d5cb80
4 changed files with 16 additions and 15 deletions
|
@ -16,6 +16,8 @@ require 'models/essay'
|
||||||
require 'models/toy'
|
require 'models/toy'
|
||||||
require 'models/invoice'
|
require 'models/invoice'
|
||||||
require 'models/line_item'
|
require 'models/line_item'
|
||||||
|
require 'models/column'
|
||||||
|
require 'models/record'
|
||||||
|
|
||||||
class BelongsToAssociationsTest < ActiveRecord::TestCase
|
class BelongsToAssociationsTest < ActiveRecord::TestCase
|
||||||
fixtures :accounts, :companies, :developers, :projects, :topics,
|
fixtures :accounts, :companies, :developers, :projects, :topics,
|
||||||
|
@ -886,21 +888,9 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'belongs_to works with model name Record' do
|
test 'belongs_to works with model called Record' do
|
||||||
Record = Class.new(ActiveRecord::Base) do
|
|
||||||
connection.create_table :records
|
|
||||||
end
|
|
||||||
|
|
||||||
Foo = Class.new(ActiveRecord::Base) do
|
|
||||||
connection.create_table :foos do |t|
|
|
||||||
t.belongs_to :record
|
|
||||||
end
|
|
||||||
|
|
||||||
belongs_to :record
|
|
||||||
end
|
|
||||||
|
|
||||||
record = Record.create!
|
record = Record.create!
|
||||||
Foo.create! record: record
|
Column.create! record: record
|
||||||
assert_equal 1, Foo.count
|
assert_equal 1, Column.count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
3
activerecord/test/models/column.rb
Normal file
3
activerecord/test/models/column.rb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
class Column < ActiveRecord::Base
|
||||||
|
belongs_to :record
|
||||||
|
end
|
2
activerecord/test/models/record.rb
Normal file
2
activerecord/test/models/record.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
class Record < ActiveRecord::Base
|
||||||
|
end
|
|
@ -161,6 +161,10 @@ ActiveRecord::Schema.define do
|
||||||
t.integer :references, null: false
|
t.integer :references, null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table :columns, force: true do |t|
|
||||||
|
t.references :record
|
||||||
|
end
|
||||||
|
|
||||||
create_table :comments, force: true do |t|
|
create_table :comments, force: true do |t|
|
||||||
t.integer :post_id, null: false
|
t.integer :post_id, null: false
|
||||||
# use VARCHAR2(4000) instead of CLOB datatype as CLOB data type has many limitations in
|
# use VARCHAR2(4000) instead of CLOB datatype as CLOB data type has many limitations in
|
||||||
|
@ -819,6 +823,8 @@ ActiveRecord::Schema.define do
|
||||||
t.integer :department_id
|
t.integer :department_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table :records, force: true do |t|
|
||||||
|
end
|
||||||
|
|
||||||
except 'SQLite' do
|
except 'SQLite' do
|
||||||
# fk_test_has_fk should be before fk_test_has_pk
|
# fk_test_has_fk should be before fk_test_has_pk
|
||||||
|
|
Loading…
Reference in a new issue