Skip to content

Commit

Permalink
Fix the test defining the models in the right place
Browse files Browse the repository at this point in the history
Conflicts:
	activerecord/test/cases/associations/belongs_to_associations_test.rb
	activerecord/test/schema/schema.rb
  • Loading branch information
rafaelfranca committed Apr 4, 2014
1 parent 1755958 commit a0804f7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
Expand Up @@ -16,6 +16,8 @@
require 'models/toy'
require 'models/invoice'
require 'models/line_item'
require 'models/column'
require 'models/record'

class BelongsToAssociationsTest < ActiveRecord::TestCase
fixtures :accounts, :companies, :developers, :projects, :topics,
Expand Down Expand Up @@ -867,21 +869,9 @@ def test_reflect_the_most_recent_change
assert_equal post.author_id, author2.id
end

test 'belongs_to works with model name 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

test 'belongs_to works with model called Record' do
record = Record.create!
Foo.create! record: record
assert_equal 1, Foo.count
Column.create! record: record
assert_equal 1, Column.count
end
end
3 changes: 3 additions & 0 deletions activerecord/test/models/column.rb
@@ -0,0 +1,3 @@
class Column < ActiveRecord::Base
belongs_to :record
end
2 changes: 2 additions & 0 deletions activerecord/test/models/record.rb
@@ -0,0 +1,2 @@
class Record < ActiveRecord::Base
end
6 changes: 6 additions & 0 deletions activerecord/test/schema/schema.rb
Expand Up @@ -158,6 +158,10 @@ def create_table(*args, &block)
t.integer :references, :null => false
end

create_table :columns, force: true do |t|
t.references :record
end

create_table :comments, :force => true do |t|
t.integer :post_id, :null => false
# use VARCHAR2(4000) instead of CLOB datatype as CLOB data type has many limitations in
Expand Down Expand Up @@ -811,6 +815,8 @@ def create_table(*args, &block)
t.integer :department_id
end

create_table :records, force: true do |t|
end

except 'SQLite' do
# fk_test_has_fk should be before fk_test_has_pk
Expand Down

0 comments on commit a0804f7

Please sign in to comment.