diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-11-03 13:26:21 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-11-03 13:27:08 -0200 |
commit | fa0aebf320995a598c5bffda729aed4429681f3a (patch) | |
tree | 429dc9fe708695fb1103ad69e20bb9ffa20ddccc /activerecord | |
parent | c449462f45d342258a01313c0ff46279d268719d (diff) | |
download | rails-fa0aebf320995a598c5bffda729aed4429681f3a.tar.gz rails-fa0aebf320995a598c5bffda729aed4429681f3a.tar.bz2 rails-fa0aebf320995a598c5bffda729aed4429681f3a.zip |
Check if the options value is present before to send the deprecation
message
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 10 | ||||
-rw-r--r-- | activerecord/test/cases/migration/references_statements_test.rb | 4 |
2 files changed, 8 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 73aaffc146..17dd71e898 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -629,11 +629,13 @@ module ActiveRecord index_options = options[:where] ? " WHERE #{options[:where]}" : "" end else - message = "Passing a string as third argument of `add_index` is deprecated and will" + - " be removed in Rails 4.1." + - " Use add_index(#{table_name.inspect}, #{column_name.inspect}, unique: true) instead" + if options + message = "Passing a string as third argument of `add_index` is deprecated and will" + + " be removed in Rails 4.1." + + " Use add_index(#{table_name.inspect}, #{column_name.inspect}, unique: true) instead" - ActiveSupport::Deprecation.warn message + ActiveSupport::Deprecation.warn message + end index_type = options end diff --git a/activerecord/test/cases/migration/references_statements_test.rb b/activerecord/test/cases/migration/references_statements_test.rb index 144302bd4a..d8a6565d54 100644 --- a/activerecord/test/cases/migration/references_statements_test.rb +++ b/activerecord/test/cases/migration/references_statements_test.rb @@ -64,7 +64,7 @@ module ActiveRecord remove_reference table_name, :supplier refute index_exists?(table_name, :supplier_id) end - + def test_does_not_delete_reference_type_column with_polymorphic_column do remove_reference table_name, :supplier @@ -73,7 +73,7 @@ module ActiveRecord assert column_exists?(table_name, :supplier_type, :string) end end - + def test_deletes_reference_type_column with_polymorphic_column do remove_reference table_name, :supplier, polymorphic: true |