aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/migration
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-08-06 18:26:20 +0200
committerXavier Noria <fxn@hashref.com>2016-08-06 18:26:53 +0200
commit9617db2078e8a85c8944392c21dd748f932bbd80 (patch)
tree727d60f1d2f9bbb6510483c366f62d75e2647619 /activerecord/test/cases/migration
parent4df2b779ddfcb27761c71e00e2b241bfa06a0950 (diff)
downloadrails-9617db2078e8a85c8944392c21dd748f932bbd80.tar.gz
rails-9617db2078e8a85c8944392c21dd748f932bbd80.tar.bz2
rails-9617db2078e8a85c8944392c21dd748f932bbd80.zip
applies new string literal convention in activerecord/test
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
Diffstat (limited to 'activerecord/test/cases/migration')
-rw-r--r--activerecord/test/cases/migration/change_schema_test.rb56
-rw-r--r--activerecord/test/cases/migration/column_attributes_test.rb34
-rw-r--r--activerecord/test/cases/migration/column_positioning_test.rb2
-rw-r--r--activerecord/test/cases/migration/columns_test.rb86
-rw-r--r--activerecord/test/cases/migration/command_recorder_test.rb20
-rw-r--r--activerecord/test/cases/migration/compatibility_test.rb10
-rw-r--r--activerecord/test/cases/migration/create_join_table_test.rb34
-rw-r--r--activerecord/test/cases/migration/foreign_key_test.rb10
-rw-r--r--activerecord/test/cases/migration/index_test.rb28
-rw-r--r--activerecord/test/cases/migration/logger_test.rb2
-rw-r--r--activerecord/test/cases/migration/pending_migrations_test.rb2
-rw-r--r--activerecord/test/cases/migration/references_foreign_key_test.rb6
-rw-r--r--activerecord/test/cases/migration/references_index_test.rb2
-rw-r--r--activerecord/test/cases/migration/references_statements_test.rb12
-rw-r--r--activerecord/test/cases/migration/rename_table_test.rb20
15 files changed, 162 insertions, 162 deletions
diff --git a/activerecord/test/cases/migration/change_schema_test.rb b/activerecord/test/cases/migration/change_schema_test.rb
index d6963b48d7..974a0ea8e2 100644
--- a/activerecord/test/cases/migration/change_schema_test.rb
+++ b/activerecord/test/cases/migration/change_schema_test.rb
@@ -1,4 +1,4 @@
-require 'cases/helper'
+require "cases/helper"
module ActiveRecord
class Migration
@@ -70,7 +70,7 @@ module ActiveRecord
assert_equal "hello", one.default
assert_equal true, connection.lookup_cast_type_from_column(two).deserialize(two.default)
assert_equal false, connection.lookup_cast_type_from_column(three).deserialize(three.default)
- assert_equal '1', four.default
+ assert_equal "1", four.default
assert_equal "hello", five.default unless mysql
end
@@ -105,9 +105,9 @@ module ActiveRecord
eight = columns.detect { |c| c.name == "eight_int" }
if current_adapter?(:OracleAdapter)
- assert_equal 'NUMBER(19)', eight.sql_type
+ assert_equal "NUMBER(19)", eight.sql_type
elsif current_adapter?(:SQLite3Adapter)
- assert_equal 'bigint', eight.sql_type
+ assert_equal "bigint", eight.sql_type
else
assert_equal :integer, eight.type
assert_equal 8, eight.limit
@@ -137,20 +137,20 @@ module ActiveRecord
eight = columns.detect { |c| c.name == "eight_int" }
if current_adapter?(:PostgreSQLAdapter)
- assert_equal 'integer', default.sql_type
- assert_equal 'smallint', one.sql_type
- assert_equal 'integer', four.sql_type
- assert_equal 'bigint', eight.sql_type
+ assert_equal "integer", default.sql_type
+ assert_equal "smallint", one.sql_type
+ assert_equal "integer", four.sql_type
+ assert_equal "bigint", eight.sql_type
elsif current_adapter?(:Mysql2Adapter)
- assert_match 'int(11)', default.sql_type
- assert_match 'tinyint', one.sql_type
- assert_match 'int', four.sql_type
- assert_match 'bigint', eight.sql_type
+ assert_match "int(11)", default.sql_type
+ assert_match "tinyint", one.sql_type
+ assert_match "int", four.sql_type
+ assert_match "bigint", eight.sql_type
elsif current_adapter?(:OracleAdapter)
- assert_equal 'NUMBER(38)', default.sql_type
- assert_equal 'NUMBER(1)', one.sql_type
- assert_equal 'NUMBER(4)', four.sql_type
- assert_equal 'NUMBER(8)', eight.sql_type
+ assert_equal "NUMBER(38)", default.sql_type
+ assert_equal "NUMBER(1)", one.sql_type
+ assert_equal "NUMBER(4)", four.sql_type
+ assert_equal "NUMBER(8)", eight.sql_type
end
end
@@ -200,8 +200,8 @@ module ActiveRecord
end
created_columns = connection.columns(table_name)
- created_at_column = created_columns.detect {|c| c.name == 'created_at' }
- updated_at_column = created_columns.detect {|c| c.name == 'updated_at' }
+ created_at_column = created_columns.detect {|c| c.name == "created_at" }
+ updated_at_column = created_columns.detect {|c| c.name == "updated_at" }
assert !created_at_column.null
assert !updated_at_column.null
@@ -213,8 +213,8 @@ module ActiveRecord
end
created_columns = connection.columns(table_name)
- created_at_column = created_columns.detect {|c| c.name == 'created_at' }
- updated_at_column = created_columns.detect {|c| c.name == 'updated_at' }
+ created_at_column = created_columns.detect {|c| c.name == "created_at" }
+ updated_at_column = created_columns.detect {|c| c.name == "updated_at" }
assert created_at_column.null
assert updated_at_column.null
@@ -259,14 +259,14 @@ module ActiveRecord
end
klass = Class.new(ActiveRecord::Base)
- klass.table_name = 'testings'
+ klass.table_name = "testings"
- assert_equal :datetime, klass.columns_hash['foo'].type
+ assert_equal :datetime, klass.columns_hash["foo"].type
if current_adapter?(:PostgreSQLAdapter)
- assert_equal 'timestamp without time zone', klass.columns_hash['foo'].sql_type
+ assert_equal "timestamp without time zone", klass.columns_hash["foo"].sql_type
else
- assert_equal klass.connection.type_to_sql('datetime'), klass.columns_hash['foo'].sql_type
+ assert_equal klass.connection.type_to_sql("datetime"), klass.columns_hash["foo"].sql_type
end
end
@@ -290,7 +290,7 @@ module ActiveRecord
t.column :title, :string
end
person_klass = Class.new(ActiveRecord::Base)
- person_klass.table_name = 'testings'
+ person_klass.table_name = "testings"
person_klass.connection.add_column "testings", "wealth", :integer, :null => false, :default => 99
person_klass.reset_column_information
@@ -329,7 +329,7 @@ module ActiveRecord
assert_equal true, person_klass.columns_hash["money"].null
# change_column_null, make it not nullable and set null values to a default value
- person_klass.connection.execute('UPDATE testings SET money = NULL')
+ person_klass.connection.execute("UPDATE testings SET money = NULL")
person_klass.connection.change_column_null "testings", "money", false, 2000
person_klass.reset_column_information
assert_nil person_klass.columns_hash["money"].default
@@ -380,7 +380,7 @@ module ActiveRecord
t.column :foo, :string, limit: 100
t.column :bar, :decimal, precision: 8, scale: 2
t.column :taggable_id, :integer, null: false
- t.column :taggable_type, :string, default: 'Photo'
+ t.column :taggable_type, :string, default: "Photo"
end
assert connection.column_exists?(:testings, :foo, :string, limit: 100)
@@ -389,7 +389,7 @@ module ActiveRecord
assert_not connection.column_exists?(:testings, :bar, :decimal, precision: nil, scale: nil)
assert connection.column_exists?(:testings, :taggable_id, :integer, null: false)
assert_not connection.column_exists?(:testings, :taggable_id, :integer, null: true)
- assert connection.column_exists?(:testings, :taggable_type, :string, default: 'Photo')
+ assert connection.column_exists?(:testings, :taggable_type, :string, default: "Photo")
assert_not connection.column_exists?(:testings, :taggable_type, :string, default: nil)
end
diff --git a/activerecord/test/cases/migration/column_attributes_test.rb b/activerecord/test/cases/migration/column_attributes_test.rb
index 2f71ba870d..847000fa0e 100644
--- a/activerecord/test/cases/migration/column_attributes_test.rb
+++ b/activerecord/test/cases/migration/column_attributes_test.rb
@@ -9,7 +9,7 @@ module ActiveRecord
def test_add_column_newline_default
string = "foo\nbar"
- add_column 'test_models', 'command', :string, :default => string
+ add_column "test_models", "command", :string, :default => string
TestModel.reset_column_information
assert_equal string, TestModel.new.command
@@ -18,10 +18,10 @@ module ActiveRecord
def test_add_remove_single_field_using_string_arguments
assert_no_column TestModel, :last_name
- add_column 'test_models', 'last_name', :string
+ add_column "test_models", "last_name", :string
assert_column TestModel, :last_name
- remove_column 'test_models', 'last_name'
+ remove_column "test_models", "last_name"
assert_no_column TestModel, :last_name
end
@@ -47,7 +47,7 @@ module ActiveRecord
def test_unabstracted_database_dependent_types
add_column :test_models, :intelligence_quotient, :tinyint
TestModel.reset_column_information
- assert_match(/tinyint/, TestModel.columns_hash['intelligence_quotient'].sql_type)
+ assert_match(/tinyint/, TestModel.columns_hash["intelligence_quotient"].sql_type)
end
end
@@ -56,9 +56,9 @@ module ActiveRecord
# functionality. This allows us to more easily catch INSERT being broken,
# but SELECT actually working fine.
def test_native_decimal_insert_manual_vs_automatic
- correct_value = '0012345678901234567890.0123456789'.to_d
+ correct_value = "0012345678901234567890.0123456789".to_d
- connection.add_column "test_models", "wealth", :decimal, :precision => '30', :scale => '10'
+ connection.add_column "test_models", "wealth", :decimal, :precision => "30", :scale => "10"
# Do a manual insertion
if current_adapter?(:OracleAdapter)
@@ -94,26 +94,26 @@ module ActiveRecord
end
def test_add_column_with_precision_and_scale
- connection.add_column 'test_models', 'wealth', :decimal, :precision => 9, :scale => 7
+ connection.add_column "test_models", "wealth", :decimal, :precision => 9, :scale => 7
- wealth_column = TestModel.columns_hash['wealth']
+ wealth_column = TestModel.columns_hash["wealth"]
assert_equal 9, wealth_column.precision
assert_equal 7, wealth_column.scale
end
if current_adapter?(:SQLite3Adapter)
def test_change_column_preserve_other_column_precision_and_scale
- connection.add_column 'test_models', 'last_name', :string
- connection.add_column 'test_models', 'wealth', :decimal, :precision => 9, :scale => 7
+ connection.add_column "test_models", "last_name", :string
+ connection.add_column "test_models", "wealth", :decimal, :precision => 9, :scale => 7
- wealth_column = TestModel.columns_hash['wealth']
+ wealth_column = TestModel.columns_hash["wealth"]
assert_equal 9, wealth_column.precision
assert_equal 7, wealth_column.scale
- connection.change_column 'test_models', 'last_name', :string, :null => false
+ connection.change_column "test_models", "last_name", :string, :null => false
TestModel.reset_column_information
- wealth_column = TestModel.columns_hash['wealth']
+ wealth_column = TestModel.columns_hash["wealth"]
assert_equal 9, wealth_column.precision
assert_equal 7, wealth_column.scale
end
@@ -126,21 +126,21 @@ module ActiveRecord
add_column "test_models", "bio", :text
add_column "test_models", "age", :integer
add_column "test_models", "height", :float
- add_column "test_models", "wealth", :decimal, :precision => '30', :scale => '10'
+ add_column "test_models", "wealth", :decimal, :precision => "30", :scale => "10"
add_column "test_models", "birthday", :datetime
add_column "test_models", "favorite_day", :date
add_column "test_models", "moment_of_truth", :datetime
add_column "test_models", "male", :boolean
- TestModel.create :first_name => 'bob', :last_name => 'bobsen',
+ TestModel.create :first_name => "bob", :last_name => "bobsen",
:bio => "I was born ....", :age => 18, :height => 1.78,
:wealth => BigDecimal.new("12345678901234567890.0123456789"),
:birthday => 18.years.ago, :favorite_day => 10.days.ago,
:moment_of_truth => "1782-10-10 21:40:18", :male => true
bob = TestModel.first
- assert_equal 'bob', bob.first_name
- assert_equal 'bobsen', bob.last_name
+ assert_equal "bob", bob.first_name
+ assert_equal "bobsen", bob.last_name
assert_equal "I was born ....", bob.bio
assert_equal 18, bob.age
diff --git a/activerecord/test/cases/migration/column_positioning_test.rb b/activerecord/test/cases/migration/column_positioning_test.rb
index 8294da0373..0a4215fa78 100644
--- a/activerecord/test/cases/migration/column_positioning_test.rb
+++ b/activerecord/test/cases/migration/column_positioning_test.rb
@@ -1,4 +1,4 @@
-require 'cases/helper'
+require "cases/helper"
module ActiveRecord
class Migration
diff --git a/activerecord/test/cases/migration/columns_test.rb b/activerecord/test/cases/migration/columns_test.rb
index fca1cb7e97..7098eb1d2c 100644
--- a/activerecord/test/cases/migration/columns_test.rb
+++ b/activerecord/test/cases/migration/columns_test.rb
@@ -13,7 +13,7 @@ module ActiveRecord
add_column "test_models", "girlfriend", :string
TestModel.reset_column_information
- TestModel.create :girlfriend => 'bobette'
+ TestModel.create :girlfriend => "bobette"
rename_column "test_models", "girlfriend", "exgirlfriend"
@@ -28,12 +28,12 @@ module ActiveRecord
def test_rename_column_using_symbol_arguments
add_column :test_models, :first_name, :string
- TestModel.create :first_name => 'foo'
+ TestModel.create :first_name => "foo"
rename_column :test_models, :first_name, :nick_name
TestModel.reset_column_information
assert TestModel.column_names.include?("nick_name")
- assert_equal ['foo'], TestModel.all.map(&:nick_name)
+ assert_equal ["foo"], TestModel.all.map(&:nick_name)
end
# FIXME: another integration test. We should decouple this from the
@@ -41,25 +41,25 @@ module ActiveRecord
def test_rename_column
add_column "test_models", "first_name", "string"
- TestModel.create :first_name => 'foo'
+ TestModel.create :first_name => "foo"
rename_column "test_models", "first_name", "nick_name"
TestModel.reset_column_information
assert TestModel.column_names.include?("nick_name")
- assert_equal ['foo'], TestModel.all.map(&:nick_name)
+ assert_equal ["foo"], TestModel.all.map(&:nick_name)
end
def test_rename_column_preserves_default_value_not_null
- add_column 'test_models', 'salary', :integer, :default => 70000
+ add_column "test_models", "salary", :integer, :default => 70000
default_before = connection.columns("test_models").find { |c| c.name == "salary" }.default
- assert_equal '70000', default_before
+ assert_equal "70000", default_before
rename_column "test_models", "salary", "annual_salary"
assert TestModel.column_names.include?("annual_salary")
default_after = connection.columns("test_models").find { |c| c.name == "annual_salary" }.default
- assert_equal '70000', default_after
+ assert_equal "70000", default_after
end
if current_adapter?(:Mysql2Adapter)
@@ -84,7 +84,7 @@ module ActiveRecord
end
def test_rename_column_with_sql_reserved_word
- add_column 'test_models', 'first_name', :string
+ add_column "test_models", "first_name", :string
rename_column "test_models", "first_name", "group"
assert TestModel.column_names.include?("group")
@@ -94,10 +94,10 @@ module ActiveRecord
add_column "test_models", :hat_name, :string
add_index :test_models, :hat_name
- assert_equal 1, connection.indexes('test_models').size
+ assert_equal 1, connection.indexes("test_models").size
rename_column "test_models", "hat_name", "name"
- assert_equal ['index_test_models_on_name'], connection.indexes('test_models').map(&:name)
+ assert_equal ["index_test_models_on_name"], connection.indexes("test_models").map(&:name)
end
def test_rename_column_with_multi_column_index
@@ -105,37 +105,37 @@ module ActiveRecord
add_column "test_models", :hat_style, :string, limit: 100
add_index "test_models", ["hat_style", "hat_size"], unique: true
- rename_column "test_models", "hat_size", 'size'
+ rename_column "test_models", "hat_size", "size"
if current_adapter? :OracleAdapter
- assert_equal ['i_test_models_hat_style_size'], connection.indexes('test_models').map(&:name)
+ assert_equal ["i_test_models_hat_style_size"], connection.indexes("test_models").map(&:name)
else
- assert_equal ['index_test_models_on_hat_style_and_size'], connection.indexes('test_models').map(&:name)
+ assert_equal ["index_test_models_on_hat_style_and_size"], connection.indexes("test_models").map(&:name)
end
- rename_column "test_models", "hat_style", 'style'
+ rename_column "test_models", "hat_style", "style"
if current_adapter? :OracleAdapter
- assert_equal ['i_test_models_style_size'], connection.indexes('test_models').map(&:name)
+ assert_equal ["i_test_models_style_size"], connection.indexes("test_models").map(&:name)
else
- assert_equal ['index_test_models_on_style_and_size'], connection.indexes('test_models').map(&:name)
+ assert_equal ["index_test_models_on_style_and_size"], connection.indexes("test_models").map(&:name)
end
end
def test_rename_column_does_not_rename_custom_named_index
add_column "test_models", :hat_name, :string
- add_index :test_models, :hat_name, :name => 'idx_hat_name'
+ add_index :test_models, :hat_name, :name => "idx_hat_name"
- assert_equal 1, connection.indexes('test_models').size
+ assert_equal 1, connection.indexes("test_models").size
rename_column "test_models", "hat_name", "name"
- assert_equal ['idx_hat_name'], connection.indexes('test_models').map(&:name)
+ assert_equal ["idx_hat_name"], connection.indexes("test_models").map(&:name)
end
def test_remove_column_with_index
add_column "test_models", :hat_name, :string
add_index :test_models, :hat_name
- assert_equal 1, connection.indexes('test_models').size
+ assert_equal 1, connection.indexes("test_models").size
remove_column("test_models", "hat_name")
- assert_equal 0, connection.indexes('test_models').size
+ assert_equal 0, connection.indexes("test_models").size
end
def test_remove_column_with_multi_column_index
@@ -143,15 +143,15 @@ module ActiveRecord
add_column "test_models", :hat_style, :string, :limit => 100
add_index "test_models", ["hat_style", "hat_size"], :unique => true
- assert_equal 1, connection.indexes('test_models').size
+ assert_equal 1, connection.indexes("test_models").size
remove_column("test_models", "hat_size")
# Every database and/or database adapter has their own behavior
# if it drops the multi-column index when any of the indexed columns dropped by remove_column.
if current_adapter?(:PostgreSQLAdapter, :OracleAdapter)
- assert_equal [], connection.indexes('test_models').map(&:name)
+ assert_equal [], connection.indexes("test_models").map(&:name)
else
- assert_equal ['index_test_models_on_hat_style_and_hat_size'], connection.indexes('test_models').map(&:name)
+ assert_equal ["index_test_models_on_hat_style_and_hat_size"], connection.indexes("test_models").map(&:name)
end
end
@@ -160,7 +160,7 @@ module ActiveRecord
change_column "test_models", "updated_at", :datetime, :null => false
TestModel.reset_column_information
- assert_equal false, TestModel.columns_hash['updated_at'].null
+ assert_equal false, TestModel.columns_hash["updated_at"].null
ensure
change_column "test_models", "updated_at", :datetime, :null => true
end
@@ -180,24 +180,24 @@ module ActiveRecord
end
def test_change_column
- add_column 'test_models', 'age', :integer
- add_column 'test_models', 'approved', :boolean, :default => true
+ add_column "test_models", "age", :integer
+ add_column "test_models", "approved", :boolean, :default => true
old_columns = connection.columns(TestModel.table_name)
- assert old_columns.find { |c| c.name == 'age' && c.type == :integer }
+ assert old_columns.find { |c| c.name == "age" && c.type == :integer }
change_column "test_models", "age", :string
new_columns = connection.columns(TestModel.table_name)
- assert_not new_columns.find { |c| c.name == 'age' and c.type == :integer }
- assert new_columns.find { |c| c.name == 'age' and c.type == :string }
+ assert_not new_columns.find { |c| c.name == "age" and c.type == :integer }
+ assert new_columns.find { |c| c.name == "age" and c.type == :string }
old_columns = connection.columns(TestModel.table_name)
assert old_columns.find { |c|
default = connection.lookup_cast_type_from_column(c).deserialize(c.default)
- c.name == 'approved' && c.type == :boolean && default == true
+ c.name == "approved" && c.type == :boolean && default == true
}
change_column :test_models, :approved, :boolean, :default => false
@@ -205,11 +205,11 @@ module ActiveRecord
assert_not new_columns.find { |c|
default = connection.lookup_cast_type_from_column(c).deserialize(c.default)
- c.name == 'approved' and c.type == :boolean and default == true
+ c.name == "approved" and c.type == :boolean and default == true
}
assert new_columns.find { |c|
default = connection.lookup_cast_type_from_column(c).deserialize(c.default)
- c.name == 'approved' and c.type == :boolean and default == false
+ c.name == "approved" and c.type == :boolean and default == false
}
change_column :test_models, :approved, :boolean, :default => true
end
@@ -235,23 +235,23 @@ module ActiveRecord
def test_change_column_with_custom_index_name
add_column "test_models", "category", :string
- add_index :test_models, :category, name: 'test_models_categories_idx'
+ add_index :test_models, :category, name: "test_models_categories_idx"
- assert_equal ['test_models_categories_idx'], connection.indexes('test_models').map(&:name)
- change_column "test_models", "category", :string, null: false, default: 'article'
+ assert_equal ["test_models_categories_idx"], connection.indexes("test_models").map(&:name)
+ change_column "test_models", "category", :string, null: false, default: "article"
- assert_equal ['test_models_categories_idx'], connection.indexes('test_models').map(&:name)
+ assert_equal ["test_models_categories_idx"], connection.indexes("test_models").map(&:name)
end
def test_change_column_with_long_index_name
- table_name_prefix = 'test_models_'
- long_index_name = table_name_prefix + ('x' * (connection.allowed_index_name_length - table_name_prefix.length))
+ table_name_prefix = "test_models_"
+ long_index_name = table_name_prefix + ("x" * (connection.allowed_index_name_length - table_name_prefix.length))
add_column "test_models", "category", :string
add_index :test_models, :category, name: long_index_name
- change_column "test_models", "category", :string, null: false, default: 'article'
+ change_column "test_models", "category", :string, null: false, default: "article"
- assert_equal [long_index_name], connection.indexes('test_models').map(&:name)
+ assert_equal [long_index_name], connection.indexes("test_models").map(&:name)
end
def test_change_column_default
@@ -287,7 +287,7 @@ module ActiveRecord
remove_column("my_table", "col_two")
rename_column("my_table", "col_one", "col_three")
- assert_equal 'my_table_id', connection.primary_key('my_table')
+ assert_equal "my_table_id", connection.primary_key("my_table")
ensure
connection.drop_table(:my_table) rescue nil
end
diff --git a/activerecord/test/cases/migration/command_recorder_test.rb b/activerecord/test/cases/migration/command_recorder_test.rb
index 1e3529db54..39f3fd99c7 100644
--- a/activerecord/test/cases/migration/command_recorder_test.rb
+++ b/activerecord/test/cases/migration/command_recorder_test.rb
@@ -25,26 +25,26 @@ module ActiveRecord
recorder = CommandRecorder.new(Class.new {
def create_table(name); end
}.new)
- assert recorder.respond_to?(:create_table), 'respond_to? create_table'
+ assert recorder.respond_to?(:create_table), "respond_to? create_table"
recorder.send(:create_table, :horses)
assert_equal [[:create_table, [:horses], nil]], recorder.commands
end
def test_unknown_commands_delegate
recorder = Struct.new(:foo)
- recorder = CommandRecorder.new(recorder.new('bar'))
- assert_equal 'bar', recorder.foo
+ recorder = CommandRecorder.new(recorder.new("bar"))
+ assert_equal "bar", recorder.foo
end
def test_inverse_of_raise_exception_on_unknown_commands
assert_raises(ActiveRecord::IrreversibleMigration) do
- @recorder.inverse_of :execute, ['some sql']
+ @recorder.inverse_of :execute, ["some sql"]
end
end
def test_irreversible_commands_raise_exception
assert_raises(ActiveRecord::IrreversibleMigration) do
- @recorder.revert{ @recorder.execute 'some sql' }
+ @recorder.revert{ @recorder.execute "some sql" }
end
end
@@ -166,7 +166,7 @@ module ActiveRecord
def test_invert_change_column_default
assert_raises(ActiveRecord::IrreversibleMigration) do
- @recorder.inverse_of :change_column_default, [:table, :column, 'default_value']
+ @recorder.inverse_of :change_column_default, [:table, :column, "default_value"]
end
end
@@ -283,13 +283,13 @@ module ActiveRecord
end
def test_invert_enable_extension
- disable = @recorder.inverse_of :enable_extension, ['uuid-ossp']
- assert_equal [:disable_extension, ['uuid-ossp'], nil], disable
+ disable = @recorder.inverse_of :enable_extension, ["uuid-ossp"]
+ assert_equal [:disable_extension, ["uuid-ossp"], nil], disable
end
def test_invert_disable_extension
- enable = @recorder.inverse_of :disable_extension, ['uuid-ossp']
- assert_equal [:enable_extension, ['uuid-ossp'], nil], enable
+ enable = @recorder.inverse_of :disable_extension, ["uuid-ossp"]
+ assert_equal [:enable_extension, ["uuid-ossp"], nil], enable
end
def test_invert_add_foreign_key
diff --git a/activerecord/test/cases/migration/compatibility_test.rb b/activerecord/test/cases/migration/compatibility_test.rb
index 60ca90464d..bb249e5deb 100644
--- a/activerecord/test/cases/migration/compatibility_test.rb
+++ b/activerecord/test/cases/migration/compatibility_test.rb
@@ -1,4 +1,4 @@
-require 'cases/helper'
+require "cases/helper"
module ActiveRecord
class Migration
@@ -83,8 +83,8 @@ module ActiveRecord
ActiveRecord::Migrator.new(:up, [migration]).migrate
- assert connection.columns(:more_testings).find { |c| c.name == 'created_at' }.null
- assert connection.columns(:more_testings).find { |c| c.name == 'updated_at' }.null
+ assert connection.columns(:more_testings).find { |c| c.name == "created_at" }.null
+ assert connection.columns(:more_testings).find { |c| c.name == "updated_at" }.null
ensure
connection.drop_table :more_testings rescue nil
end
@@ -98,8 +98,8 @@ module ActiveRecord
ActiveRecord::Migrator.new(:up, [migration]).migrate
- assert connection.columns(:testings).find { |c| c.name == 'created_at' }.null
- assert connection.columns(:testings).find { |c| c.name == 'updated_at' }.null
+ assert connection.columns(:testings).find { |c| c.name == "created_at" }.null
+ assert connection.columns(:testings).find { |c| c.name == "updated_at" }.null
end
def test_legacy_migrations_get_deprecation_warning_when_run
diff --git a/activerecord/test/cases/migration/create_join_table_test.rb b/activerecord/test/cases/migration/create_join_table_test.rb
index 920c472c73..372ec40a04 100644
--- a/activerecord/test/cases/migration/create_join_table_test.rb
+++ b/activerecord/test/cases/migration/create_join_table_test.rb
@@ -1,4 +1,4 @@
-require 'cases/helper'
+require "cases/helper"
module ActiveRecord
class Migration
@@ -31,13 +31,13 @@ module ActiveRecord
end
def test_create_join_table_with_strings
- connection.create_join_table 'artists', 'musics'
+ connection.create_join_table "artists", "musics"
assert_equal %w(artist_id music_id), connection.columns(:artists_musics).map(&:name).sort
end
def test_create_join_table_with_symbol_and_string
- connection.create_join_table :artists, 'musics'
+ connection.create_join_table :artists, "musics"
assert_equal %w(artist_id music_id), connection.columns(:artists_musics).map(&:name).sort
end
@@ -55,7 +55,7 @@ module ActiveRecord
end
def test_create_join_table_with_the_table_name_as_string
- connection.create_join_table :artists, :musics, table_name: 'catalog'
+ connection.create_join_table :artists, :musics, table_name: "catalog"
assert_equal %w(artist_id music_id), connection.columns(:catalog).map(&:name).sort
end
@@ -84,51 +84,51 @@ module ActiveRecord
connection.create_join_table :artists, :musics
connection.drop_join_table :artists, :musics
- ActiveSupport::Deprecation.silence { assert !connection.table_exists?('artists_musics') }
+ ActiveSupport::Deprecation.silence { assert !connection.table_exists?("artists_musics") }
end
def test_drop_join_table_with_strings
connection.create_join_table :artists, :musics
- connection.drop_join_table 'artists', 'musics'
+ connection.drop_join_table "artists", "musics"
- ActiveSupport::Deprecation.silence { assert !connection.table_exists?('artists_musics') }
+ ActiveSupport::Deprecation.silence { assert !connection.table_exists?("artists_musics") }
end
def test_drop_join_table_with_the_proper_order
connection.create_join_table :videos, :musics
connection.drop_join_table :videos, :musics
- ActiveSupport::Deprecation.silence { assert !connection.table_exists?('musics_videos') }
+ ActiveSupport::Deprecation.silence { assert !connection.table_exists?("musics_videos") }
end
def test_drop_join_table_with_the_table_name
connection.create_join_table :artists, :musics, table_name: :catalog
connection.drop_join_table :artists, :musics, table_name: :catalog
- ActiveSupport::Deprecation.silence { assert !connection.table_exists?('catalog') }
+ ActiveSupport::Deprecation.silence { assert !connection.table_exists?("catalog") }
end
def test_drop_join_table_with_the_table_name_as_string
- connection.create_join_table :artists, :musics, table_name: 'catalog'
- connection.drop_join_table :artists, :musics, table_name: 'catalog'
+ connection.create_join_table :artists, :musics, table_name: "catalog"
+ connection.drop_join_table :artists, :musics, table_name: "catalog"
- ActiveSupport::Deprecation.silence { assert !connection.table_exists?('catalog') }
+ ActiveSupport::Deprecation.silence { assert !connection.table_exists?("catalog") }
end
def test_drop_join_table_with_column_options
connection.create_join_table :artists, :musics, column_options: {null: true}
connection.drop_join_table :artists, :musics, column_options: {null: true}
- ActiveSupport::Deprecation.silence { assert !connection.table_exists?('artists_musics') }
+ ActiveSupport::Deprecation.silence { assert !connection.table_exists?("artists_musics") }
end
def test_create_and_drop_join_table_with_common_prefix
with_table_cleanup do
- connection.create_join_table 'audio_artists', 'audio_musics'
- ActiveSupport::Deprecation.silence { assert connection.table_exists?('audio_artists_musics') }
+ connection.create_join_table "audio_artists", "audio_musics"
+ ActiveSupport::Deprecation.silence { assert connection.table_exists?("audio_artists_musics") }
- connection.drop_join_table 'audio_artists', 'audio_musics'
- ActiveSupport::Deprecation.silence { assert !connection.table_exists?('audio_artists_musics'), "Should have dropped join table, but didn't" }
+ connection.drop_join_table "audio_artists", "audio_musics"
+ ActiveSupport::Deprecation.silence { assert !connection.table_exists?("audio_artists_musics"), "Should have dropped join table, but didn't" }
end
end
diff --git a/activerecord/test/cases/migration/foreign_key_test.rb b/activerecord/test/cases/migration/foreign_key_test.rb
index 4237e89731..b47df24b13 100644
--- a/activerecord/test/cases/migration/foreign_key_test.rb
+++ b/activerecord/test/cases/migration/foreign_key_test.rb
@@ -1,6 +1,6 @@
-require 'cases/helper'
-require 'support/ddl_helper'
-require 'support/schema_dumping_helper'
+require "cases/helper"
+require "support/ddl_helper"
+require "support/schema_dumping_helper"
if ActiveRecord::Base.connection.supports_foreign_keys?
module ActiveRecord
@@ -268,7 +268,7 @@ module ActiveRecord
end
def test_add_foreign_key_with_prefix
- ActiveRecord::Base.table_name_prefix = 'p_'
+ ActiveRecord::Base.table_name_prefix = "p_"
migration = CreateSchoolsAndClassesMigration.new
silence_stream($stdout) { migration.migrate(:up) }
assert_equal 1, @connection.foreign_keys("p_classes").size
@@ -278,7 +278,7 @@ module ActiveRecord
end
def test_add_foreign_key_with_suffix
- ActiveRecord::Base.table_name_suffix = '_s'
+ ActiveRecord::Base.table_name_suffix = "_s"
migration = CreateSchoolsAndClassesMigration.new
silence_stream($stdout) { migration.migrate(:up) }
assert_equal 1, @connection.foreign_keys("classes_s").size
diff --git a/activerecord/test/cases/migration/index_test.rb b/activerecord/test/cases/migration/index_test.rb
index 5abd37bfa2..d9b2bc9957 100644
--- a/activerecord/test/cases/migration/index_test.rb
+++ b/activerecord/test/cases/migration/index_test.rb
@@ -1,4 +1,4 @@
-require 'cases/helper'
+require "cases/helper"
module ActiveRecord
class Migration
@@ -28,32 +28,32 @@ module ActiveRecord
def test_rename_index
# keep the names short to make Oracle and similar behave
- connection.add_index(table_name, [:foo], :name => 'old_idx')
- connection.rename_index(table_name, 'old_idx', 'new_idx')
+ connection.add_index(table_name, [:foo], :name => "old_idx")
+ connection.rename_index(table_name, "old_idx", "new_idx")
# if the adapter doesn't support the indexes call, pick defaults that let the test pass
- assert_not connection.index_name_exists?(table_name, 'old_idx', false)
- assert connection.index_name_exists?(table_name, 'new_idx', true)
+ assert_not connection.index_name_exists?(table_name, "old_idx", false)
+ assert connection.index_name_exists?(table_name, "new_idx", true)
end
def test_rename_index_too_long
- too_long_index_name = good_index_name + 'x'
+ too_long_index_name = good_index_name + "x"
# keep the names short to make Oracle and similar behave
- connection.add_index(table_name, [:foo], :name => 'old_idx')
+ connection.add_index(table_name, [:foo], :name => "old_idx")
e = assert_raises(ArgumentError) {
- connection.rename_index(table_name, 'old_idx', too_long_index_name)
+ connection.rename_index(table_name, "old_idx", too_long_index_name)
}
assert_match(/too long; the limit is #{connection.allowed_index_name_length} characters/, e.message)
# if the adapter doesn't support the indexes call, pick defaults that let the test pass
- assert connection.index_name_exists?(table_name, 'old_idx', false)
+ assert connection.index_name_exists?(table_name, "old_idx", false)
end
def test_double_add_index
- connection.add_index(table_name, [:foo], :name => 'some_idx')
+ connection.add_index(table_name, [:foo], :name => "some_idx")
assert_raises(ArgumentError) {
- connection.add_index(table_name, [:foo], :name => 'some_idx')
+ connection.add_index(table_name, [:foo], :name => "some_idx")
}
end
@@ -69,7 +69,7 @@ module ActiveRecord
end
def test_add_index_does_not_accept_too_long_index_names
- too_long_index_name = good_index_name + 'x'
+ too_long_index_name = good_index_name + "x"
e = assert_raises(ArgumentError) {
connection.add_index(table_name, "foo", name: too_long_index_name)
@@ -81,7 +81,7 @@ module ActiveRecord
end
def test_internal_index_with_name_matching_database_limit
- good_index_name = 'x' * connection.index_name_length
+ good_index_name = "x" * connection.index_name_length
connection.add_index(table_name, "foo", name: good_index_name, internal: true)
assert connection.index_name_exists?(table_name, good_index_name, false)
@@ -210,7 +210,7 @@ module ActiveRecord
private
def good_index_name
- 'x' * connection.allowed_index_name_length
+ "x" * connection.allowed_index_name_length
end
end
diff --git a/activerecord/test/cases/migration/logger_test.rb b/activerecord/test/cases/migration/logger_test.rb
index bf6e684887..72d4345702 100644
--- a/activerecord/test/cases/migration/logger_test.rb
+++ b/activerecord/test/cases/migration/logger_test.rb
@@ -26,7 +26,7 @@ module ActiveRecord
def test_migration_should_be_run_without_logger
previous_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
- migrations = [Migration.new('a', 1), Migration.new('b', 2), Migration.new('c', 3)]
+ migrations = [Migration.new("a", 1), Migration.new("b", 2), Migration.new("c", 3)]
ActiveRecord::Migrator.new(:up, migrations).migrate
ensure
ActiveRecord::Base.logger = previous_logger
diff --git a/activerecord/test/cases/migration/pending_migrations_test.rb b/activerecord/test/cases/migration/pending_migrations_test.rb
index 4f5589f32a..61f5a061b0 100644
--- a/activerecord/test/cases/migration/pending_migrations_test.rb
+++ b/activerecord/test/cases/migration/pending_migrations_test.rb
@@ -1,4 +1,4 @@
-require 'cases/helper'
+require "cases/helper"
module ActiveRecord
class Migration
diff --git a/activerecord/test/cases/migration/references_foreign_key_test.rb b/activerecord/test/cases/migration/references_foreign_key_test.rb
index 9e19eb9f73..992d003e7e 100644
--- a/activerecord/test/cases/migration/references_foreign_key_test.rb
+++ b/activerecord/test/cases/migration/references_foreign_key_test.rb
@@ -1,4 +1,4 @@
-require 'cases/helper'
+require "cases/helper"
if ActiveRecord::Base.connection.supports_foreign_keys?
module ActiveRecord
@@ -156,7 +156,7 @@ module ActiveRecord
end
def test_references_foreign_key_with_prefix
- ActiveRecord::Base.table_name_prefix = 'p_'
+ ActiveRecord::Base.table_name_prefix = "p_"
migration = CreateDogsMigration.new
silence_stream($stdout) { migration.migrate(:up) }
assert_equal 1, @connection.foreign_keys("p_dogs").size
@@ -166,7 +166,7 @@ module ActiveRecord
end
def test_references_foreign_key_with_suffix
- ActiveRecord::Base.table_name_suffix = '_s'
+ ActiveRecord::Base.table_name_suffix = "_s"
migration = CreateDogsMigration.new
silence_stream($stdout) { migration.migrate(:up) }
assert_equal 1, @connection.foreign_keys("dogs_s").size
diff --git a/activerecord/test/cases/migration/references_index_test.rb b/activerecord/test/cases/migration/references_index_test.rb
index a9a7f0f4c4..481fe42a8b 100644
--- a/activerecord/test/cases/migration/references_index_test.rb
+++ b/activerecord/test/cases/migration/references_index_test.rb
@@ -1,4 +1,4 @@
-require 'cases/helper'
+require "cases/helper"
module ActiveRecord
class Migration
diff --git a/activerecord/test/cases/migration/references_statements_test.rb b/activerecord/test/cases/migration/references_statements_test.rb
index 5dddb35c4c..8d0acaaa6e 100644
--- a/activerecord/test/cases/migration/references_statements_test.rb
+++ b/activerecord/test/cases/migration/references_statements_test.rb
@@ -46,18 +46,18 @@ module ActiveRecord
end
def test_creates_reference_type_column_with_default
- add_reference table_name, :taggable, polymorphic: { default: 'Photo' }, index: true
- assert column_exists?(table_name, :taggable_type, :string, default: 'Photo')
+ add_reference table_name, :taggable, polymorphic: { default: "Photo" }, index: true
+ assert column_exists?(table_name, :taggable_type, :string, default: "Photo")
end
def test_creates_named_index
- add_reference table_name, :tag, index: { name: 'index_taggings_on_tag_id' }
- assert index_exists?(table_name, :tag_id, name: 'index_taggings_on_tag_id')
+ add_reference table_name, :tag, index: { name: "index_taggings_on_tag_id" }
+ assert index_exists?(table_name, :tag_id, name: "index_taggings_on_tag_id")
end
def test_creates_named_unique_index
- add_reference table_name, :tag, index: { name: 'index_taggings_on_tag_id', unique: true }
- assert index_exists?(table_name, :tag_id, name: 'index_taggings_on_tag_id', unique: true )
+ add_reference table_name, :tag, index: { name: "index_taggings_on_tag_id", unique: true }
+ assert index_exists?(table_name, :tag_id, name: "index_taggings_on_tag_id", unique: true )
end
def test_creates_reference_id_with_specified_type
diff --git a/activerecord/test/cases/migration/rename_table_test.rb b/activerecord/test/cases/migration/rename_table_test.rb
index b926a92849..5474c9ce71 100644
--- a/activerecord/test/cases/migration/rename_table_test.rb
+++ b/activerecord/test/cases/migration/rename_table_test.rb
@@ -9,9 +9,9 @@ module ActiveRecord
def setup
super
- add_column 'test_models', :url, :string
- remove_column 'test_models', :created_at
- remove_column 'test_models', :updated_at
+ add_column "test_models", :url, :string
+ remove_column "test_models", :created_at
+ remove_column "test_models", :updated_at
end
def teardown
@@ -31,7 +31,7 @@ module ActiveRecord
# Using explicit id in insert for compatibility across all databases
connection.execute "INSERT INTO 'references' (url, created_at, updated_at) VALUES ('http://rubyonrails.com', 0, 0)"
- assert_equal 'http://rubyonrails.com', connection.select_value("SELECT url FROM 'references' WHERE id=1")
+ assert_equal "http://rubyonrails.com", connection.select_value("SELECT url FROM 'references' WHERE id=1")
ensure
return unless renamed
connection.rename_table :references, :test_models
@@ -45,7 +45,7 @@ module ActiveRecord
connection.execute "INSERT INTO octopi (#{connection.quote_column_name('id')}, #{connection.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')"
- assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', connection.select_value("SELECT url FROM octopi WHERE id=1")
+ assert_equal "http://www.foreverflying.com/octopus-black7.jpg", connection.select_value("SELECT url FROM octopi WHERE id=1")
end
def test_rename_table_with_an_index
@@ -55,18 +55,18 @@ module ActiveRecord
connection.execute "INSERT INTO octopi (#{connection.quote_column_name('id')}, #{connection.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')"
- assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', connection.select_value("SELECT url FROM octopi WHERE id=1")
+ assert_equal "http://www.foreverflying.com/octopus-black7.jpg", connection.select_value("SELECT url FROM octopi WHERE id=1")
index = connection.indexes(:octopi).first
assert index.columns.include?("url")
- assert_equal 'index_octopi_on_url', index.name
+ assert_equal "index_octopi_on_url", index.name
end
def test_rename_table_does_not_rename_custom_named_index
- add_index :test_models, :url, name: 'special_url_idx'
+ add_index :test_models, :url, name: "special_url_idx"
rename_table :test_models, :octopi
- assert_equal ['special_url_idx'], connection.indexes(:octopi).map(&:name)
+ assert_equal ["special_url_idx"], connection.indexes(:octopi).map(&:name)
end
end
@@ -74,7 +74,7 @@ module ActiveRecord
def test_rename_table_for_postgresql_should_also_rename_default_sequence
rename_table :test_models, :octopi
- pk, seq = connection.pk_and_sequence_for('octopi')
+ pk, seq = connection.pk_and_sequence_for("octopi")
assert_equal ConnectionAdapters::PostgreSQL::Name.new("public", "octopi_#{pk}_seq"), seq
end