mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
add_reference/remove_reference takes keyword arguments
This commit is contained in:
parent
63783fdba2
commit
2b2673cb1e
2 changed files with 22 additions and 6 deletions
|
@ -664,7 +664,7 @@ module ActiveRecord
|
|||
# See {connection.add_reference}[rdoc-ref:SchemaStatements#add_reference] for details of the options you can use.
|
||||
def references(*args, **options)
|
||||
args.each do |ref_name|
|
||||
@base.add_reference(name, ref_name, options)
|
||||
@base.add_reference(name, ref_name, **options)
|
||||
end
|
||||
end
|
||||
alias :belongs_to :references
|
||||
|
@ -677,7 +677,7 @@ module ActiveRecord
|
|||
# See {connection.remove_reference}[rdoc-ref:SchemaStatements#remove_reference]
|
||||
def remove_references(*args, **options)
|
||||
args.each do |ref_name|
|
||||
@base.remove_reference(name, ref_name, options)
|
||||
@base.remove_reference(name, ref_name, **options)
|
||||
end
|
||||
end
|
||||
alias :remove_belongs_to :remove_references
|
||||
|
|
|
@ -19,28 +19,44 @@ module ActiveRecord
|
|||
|
||||
def test_references_column_type_adds_id
|
||||
with_change_table do |t|
|
||||
if RUBY_VERSION < "2.7"
|
||||
@connection.expect :add_reference, nil, [:delete_me, :customer, {}]
|
||||
else
|
||||
@connection.expect :add_reference, nil, [:delete_me, :customer]
|
||||
end
|
||||
t.references :customer
|
||||
end
|
||||
end
|
||||
|
||||
def test_remove_references_column_type_removes_id
|
||||
with_change_table do |t|
|
||||
if RUBY_VERSION < "2.7"
|
||||
@connection.expect :remove_reference, nil, [:delete_me, :customer, {}]
|
||||
else
|
||||
@connection.expect :remove_reference, nil, [:delete_me, :customer]
|
||||
end
|
||||
t.remove_references :customer
|
||||
end
|
||||
end
|
||||
|
||||
def test_add_belongs_to_works_like_add_references
|
||||
with_change_table do |t|
|
||||
if RUBY_VERSION < "2.7"
|
||||
@connection.expect :add_reference, nil, [:delete_me, :customer, {}]
|
||||
else
|
||||
@connection.expect :add_reference, nil, [:delete_me, :customer]
|
||||
end
|
||||
t.belongs_to :customer
|
||||
end
|
||||
end
|
||||
|
||||
def test_remove_belongs_to_works_like_remove_references
|
||||
with_change_table do |t|
|
||||
if RUBY_VERSION < "2.7"
|
||||
@connection.expect :remove_reference, nil, [:delete_me, :customer, {}]
|
||||
else
|
||||
@connection.expect :remove_reference, nil, [:delete_me, :customer]
|
||||
end
|
||||
t.remove_belongs_to :customer
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue