aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2016-08-16 05:29:32 -0300
committerGitHub <noreply@github.com>2016-08-16 05:29:32 -0300
commit1a52ed178423dd727653c31398045993cd8c8cb8 (patch)
tree12b324548516f7675ce20e52e28779c41345322d /activerecord
parent737fa371050e4b58a1b91e908f338b525b468536 (diff)
parente7023cb8f153a1b340c24c9b2525e8b27567ebdb (diff)
downloadrails-1a52ed178423dd727653c31398045993cd8c8cb8.tar.gz
rails-1a52ed178423dd727653c31398045993cd8c8cb8.tar.bz2
rails-1a52ed178423dd727653c31398045993cd8c8cb8.zip
Merge pull request #26151 from kamipo/avoid_to_allow_unused_splat_args
Avoid to allow unused splat args for `t.timestamps` in `create_table`
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb4
-rw-r--r--activerecord/lib/active_record/migration/compatibility.rb4
-rw-r--r--activerecord/test/cases/timestamp_test.rb2
3 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
index c636563e99..d9a799676f 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -341,9 +341,7 @@ module ActiveRecord
# <tt>:updated_at</tt> to the table. See {connection.add_timestamps}[rdoc-ref:SchemaStatements#add_timestamps]
#
# t.timestamps null: false
- def timestamps(*args)
- options = args.extract_options!
-
+ def timestamps(**options)
options[:null] = false if options[:null].nil?
column(:created_at, :datetime, options)
diff --git a/activerecord/lib/active_record/migration/compatibility.rb b/activerecord/lib/active_record/migration/compatibility.rb
index a79251f908..04e538baa5 100644
--- a/activerecord/lib/active_record/migration/compatibility.rb
+++ b/activerecord/lib/active_record/migration/compatibility.rb
@@ -21,7 +21,7 @@ module ActiveRecord
end
alias :belongs_to :references
- def timestamps(*, **options)
+ def timestamps(**options)
options[:null] = true if options[:null].nil?
super
end
@@ -59,7 +59,7 @@ module ActiveRecord
end
alias :add_belongs_to :add_reference
- def add_timestamps(*, **options)
+ def add_timestamps(_, **options)
options[:null] = true if options[:null].nil?
super
end
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb
index 519d9db601..cd83518e84 100644
--- a/activerecord/test/cases/timestamp_test.rb
+++ b/activerecord/test/cases/timestamp_test.rb
@@ -462,7 +462,7 @@ class TimestampTest < ActiveRecord::TestCase
def test_index_is_created_for_both_timestamps
ActiveRecord::Base.connection.create_table(:foos, force: true) do |t|
- t.timestamps(:foos, null: true, index: true)
+ t.timestamps null: true, index: true
end
indexes = ActiveRecord::Base.connection.indexes("foos")