diff options
author | Xavier Noria <fxn@hashref.com> | 2016-08-06 19:44:11 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-08-06 19:44:11 +0200 |
commit | 411ccbdab2608c62aabdb320d52cb02d446bb39c (patch) | |
tree | 05671553ac2a23dd1db4d11949c1ac43c3dd1367 /activerecord/test/cases | |
parent | 60b67d76dc1d98e4269aac7705e9d8323eb42942 (diff) | |
download | rails-411ccbdab2608c62aabdb320d52cb02d446bb39c.tar.gz rails-411ccbdab2608c62aabdb320d52cb02d446bb39c.tar.bz2 rails-411ccbdab2608c62aabdb320d52cb02d446bb39c.zip |
remove redundant curlies from hash arguments
Diffstat (limited to 'activerecord/test/cases')
21 files changed, 84 insertions, 92 deletions
diff --git a/activerecord/test/cases/adapters/mysql2/active_schema_test.rb b/activerecord/test/cases/adapters/mysql2/active_schema_test.rb index 716b7b1164..e7e37cac36 100644 --- a/activerecord/test/cases/adapters/mysql2/active_schema_test.rb +++ b/activerecord/test/cases/adapters/mysql2/active_schema_test.rb @@ -102,13 +102,13 @@ class Mysql2ActiveSchemaTest < ActiveRecord::Mysql2TestCase def test_create_mysql_database_with_encoding assert_equal "CREATE DATABASE `matt` DEFAULT CHARACTER SET `utf8`", create_database(:matt) - assert_equal "CREATE DATABASE `aimonetti` DEFAULT CHARACTER SET `latin1`", create_database(:aimonetti, {charset: "latin1"}) - assert_equal "CREATE DATABASE `matt_aimonetti` DEFAULT CHARACTER SET `big5` COLLATE `big5_chinese_ci`", create_database(:matt_aimonetti, {charset: :big5, collation: :big5_chinese_ci}) + assert_equal "CREATE DATABASE `aimonetti` DEFAULT CHARACTER SET `latin1`", create_database(:aimonetti, charset: "latin1") + assert_equal "CREATE DATABASE `matt_aimonetti` DEFAULT CHARACTER SET `big5` COLLATE `big5_chinese_ci`", create_database(:matt_aimonetti, charset: :big5, collation: :big5_chinese_ci) end def test_recreate_mysql_database_with_encoding - create_database(:luca, {charset: "latin1"}) - assert_equal "CREATE DATABASE `luca` DEFAULT CHARACTER SET `latin1`", recreate_database(:luca, {charset: "latin1"}) + create_database(:luca, charset: "latin1") + assert_equal "CREATE DATABASE `luca` DEFAULT CHARACTER SET `latin1`", recreate_database(:luca, charset: "latin1") end def test_add_column @@ -142,7 +142,7 @@ class Mysql2ActiveSchemaTest < ActiveRecord::Mysql2TestCase ActiveRecord::Base.connection.create_table :delete_me do |t| t.timestamps null: true end - ActiveRecord::Base.connection.remove_timestamps :delete_me, { null: true } + ActiveRecord::Base.connection.remove_timestamps :delete_me, null: true assert !column_present?("delete_me", "updated_at", "datetime") assert !column_present?("delete_me", "created_at", "datetime") ensure diff --git a/activerecord/test/cases/adapters/mysql2/connection_test.rb b/activerecord/test/cases/adapters/mysql2/connection_test.rb index b6ed20abaa..475269d5cb 100644 --- a/activerecord/test/cases/adapters/mysql2/connection_test.rb +++ b/activerecord/test/cases/adapters/mysql2/connection_test.rb @@ -100,21 +100,21 @@ class Mysql2ConnectionTest < ActiveRecord::Mysql2TestCase def test_passing_arbitary_flags_to_adapter run_without_connection do |orig_connection| - ActiveRecord::Base.establish_connection(orig_connection.merge({flags: Mysql2::Client::COMPRESS})) + ActiveRecord::Base.establish_connection(orig_connection.merge(flags: Mysql2::Client::COMPRESS)) assert_equal (Mysql2::Client::COMPRESS | Mysql2::Client::FOUND_ROWS), ActiveRecord::Base.connection.raw_connection.query_options[:flags] end end def test_passing_flags_by_array_to_adapter run_without_connection do |orig_connection| - ActiveRecord::Base.establish_connection(orig_connection.merge({flags: ["COMPRESS"] })) + ActiveRecord::Base.establish_connection(orig_connection.merge(flags: ["COMPRESS"])) assert_equal ["COMPRESS", "FOUND_ROWS"], ActiveRecord::Base.connection.raw_connection.query_options[:flags] end end def test_mysql_set_session_variable run_without_connection do |orig_connection| - ActiveRecord::Base.establish_connection(orig_connection.deep_merge({variables: {default_week_format: 3}})) + ActiveRecord::Base.establish_connection(orig_connection.deep_merge(variables: {default_week_format: 3})) session_mode = ActiveRecord::Base.connection.exec_query "SELECT @@SESSION.DEFAULT_WEEK_FORMAT" assert_equal 3, session_mode.rows.first.first.to_i end @@ -122,7 +122,7 @@ class Mysql2ConnectionTest < ActiveRecord::Mysql2TestCase def test_mysql_set_session_variable_to_default run_without_connection do |orig_connection| - ActiveRecord::Base.establish_connection(orig_connection.deep_merge({variables: {default_week_format: :default}})) + ActiveRecord::Base.establish_connection(orig_connection.deep_merge(variables: {default_week_format: :default})) global_mode = ActiveRecord::Base.connection.exec_query "SELECT @@GLOBAL.DEFAULT_WEEK_FORMAT" session_mode = ActiveRecord::Base.connection.exec_query "SELECT @@SESSION.DEFAULT_WEEK_FORMAT" assert_equal global_mode.rows, session_mode.rows diff --git a/activerecord/test/cases/adapters/postgresql/connection_test.rb b/activerecord/test/cases/adapters/postgresql/connection_test.rb index adb5422a67..78b4bfbdaa 100644 --- a/activerecord/test/cases/adapters/postgresql/connection_test.rb +++ b/activerecord/test/cases/adapters/postgresql/connection_test.rb @@ -184,7 +184,7 @@ module ActiveRecord def test_set_session_variable_true run_without_connection do |orig_connection| - ActiveRecord::Base.establish_connection(orig_connection.deep_merge({variables: {debug_print_plan: true}})) + ActiveRecord::Base.establish_connection(orig_connection.deep_merge(variables: {debug_print_plan: true})) set_true = ActiveRecord::Base.connection.exec_query "SHOW DEBUG_PRINT_PLAN" assert_equal set_true.rows, [["on"]] end @@ -192,7 +192,7 @@ module ActiveRecord def test_set_session_variable_false run_without_connection do |orig_connection| - ActiveRecord::Base.establish_connection(orig_connection.deep_merge({variables: {debug_print_plan: false}})) + ActiveRecord::Base.establish_connection(orig_connection.deep_merge(variables: {debug_print_plan: false})) set_false = ActiveRecord::Base.connection.exec_query "SHOW DEBUG_PRINT_PLAN" assert_equal set_false.rows, [["off"]] end @@ -201,14 +201,14 @@ module ActiveRecord def test_set_session_variable_nil run_without_connection do |orig_connection| # This should be a no-op that does not raise an error - ActiveRecord::Base.establish_connection(orig_connection.deep_merge({variables: {debug_print_plan: nil}})) + ActiveRecord::Base.establish_connection(orig_connection.deep_merge(variables: {debug_print_plan: nil})) end end def test_set_session_variable_default run_without_connection do |orig_connection| # This should execute a query that does not raise an error - ActiveRecord::Base.establish_connection(orig_connection.deep_merge({variables: {debug_print_plan: :default}})) + ActiveRecord::Base.establish_connection(orig_connection.deep_merge(variables: {debug_print_plan: :default})) end end diff --git a/activerecord/test/cases/adapters/postgresql/hstore_test.rb b/activerecord/test/cases/adapters/postgresql/hstore_test.rb index 04631cb5e5..6197e517d5 100644 --- a/activerecord/test/cases/adapters/postgresql/hstore_test.rb +++ b/activerecord/test/cases/adapters/postgresql/hstore_test.rb @@ -166,19 +166,19 @@ if ActiveRecord::Base.connection.supports_extensions? end def test_gen1 - assert_equal(%q(" "=>""), @type.serialize({" "=>""})) + assert_equal(%q(" "=>""), @type.serialize(" "=>"")) end def test_gen2 - assert_equal(%q(","=>""), @type.serialize({","=>""})) + assert_equal(%q(","=>""), @type.serialize(","=>"")) end def test_gen3 - assert_equal(%q("="=>""), @type.serialize({"="=>""})) + assert_equal(%q("="=>""), @type.serialize("="=>"")) end def test_gen4 - assert_equal(%q(">"=>""), @type.serialize({">"=>""})) + assert_equal(%q(">"=>""), @type.serialize(">"=>"")) end def test_parse1 @@ -300,7 +300,7 @@ if ActiveRecord::Base.connection.supports_extensions? end def test_hstore_with_serialized_attributes - HstoreWithSerialize.create! tags: TagCollection.new({"one" => "two"}) + HstoreWithSerialize.create! tags: TagCollection.new("one" => "two") record = HstoreWithSerialize.first assert_instance_of TagCollection, record.tags assert_equal({"one" => "two"}, record.tags.to_hash) @@ -310,7 +310,7 @@ if ActiveRecord::Base.connection.supports_extensions? end def test_clone_hstore_with_serialized_attributes - HstoreWithSerialize.create! tags: TagCollection.new({"one" => "two"}) + HstoreWithSerialize.create! tags: TagCollection.new("one" => "two") record = HstoreWithSerialize.first dupe = record.dup assert_equal({"one" => "two"}, dupe.tags.to_hash) diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index 67931ed228..c4f174e470 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -283,11 +283,9 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase end def test_habtm_collection_size_from_params - devel = Developer.new({ - projects_attributes: { + devel = Developer.new( projects_attributes: { "0" => {} - } - }) + }) assert_equal 1, devel.projects.size end diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index b513c40f48..09692fc3a0 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -682,7 +682,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase firm = Firm.all.merge!(order: "id").first summit = firm.clients.where("name = 'Summit'").to_a assert_equal summit, firm.clients.where("name = ?", "Summit").to_a - assert_equal summit, firm.clients.where("name = :name", { name: "Summit" }).to_a + assert_equal summit, firm.clients.where("name = :name", name: "Summit").to_a end def test_find_first @@ -1978,8 +1978,8 @@ class HasManyAssociationsTest < ActiveRecord::TestCase old = ActiveRecord::Base.store_full_sti_class ActiveRecord::Base.store_full_sti_class = true - firm = Namespaced::Firm.create({ name: "Some Company" }) - firm.clients.create({ name: "Some Client" }) + firm = Namespaced::Firm.create(name: "Some Company") + firm.clients.create(name: "Some Client") stats = Namespaced::Firm.all.merge!( select: "#{Namespaced::Firm.table_name}.id, COUNT(#{Namespaced::Client.table_name}.id) AS num_clients", diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 102884d255..8aad272bfd 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -197,7 +197,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase if current_adapter?(:Mysql2Adapter) test "read attributes_before_type_cast on a boolean" do - bool = Boolean.create!({ "value" => false }) + bool = Boolean.create!("value" => false) if RUBY_PLATFORM.include?("java") # JRuby will return the value before typecast as string. assert_equal "0", bool.reload.attributes_before_type_cast["value"] diff --git a/activerecord/test/cases/attribute_set_test.rb b/activerecord/test/cases/attribute_set_test.rb index 4dfe40bea6..059b5b2401 100644 --- a/activerecord/test/cases/attribute_set_test.rb +++ b/activerecord/test/cases/attribute_set_test.rb @@ -14,7 +14,7 @@ module ActiveRecord test "building with custom types" do builder = AttributeSet::Builder.new(foo: Type::Float.new) - attributes = builder.build_from_database({ foo: "3.3", bar: "4.4" }, { bar: Type::Integer.new }) + attributes = builder.build_from_database({ foo: "3.3", bar: "4.4" }, bar: Type::Integer.new) assert_equal 3.3, attributes[:foo].value assert_equal 4, attributes[:bar].value diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index e26b2445b8..7d619c6a91 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -279,16 +279,14 @@ class BasicsTest < ActiveRecord::TestCase end def test_initialize_with_attributes - topic = Topic.new({ - "title" => "initialized from attributes", "written_on" => "2003-12-12 23:23" - }) + topic = Topic.new( "title" => "initialized from attributes", "written_on" => "2003-12-12 23:23") assert_equal("initialized from attributes", topic.title) end def test_initialize_with_invalid_attribute - Topic.new({ "title" => "test", - "last_read(1i)" => "2005", "last_read(2i)" => "2", "last_read(3i)" => "31"}) + Topic.new("title" => "test", + "last_read(1i)" => "2005", "last_read(2i)" => "2", "last_read(3i)" => "31") rescue ActiveRecord::MultiparameterAssignmentErrors => ex assert_equal(1, ex.errors.size) assert_equal("last_read", ex.errors[0].attribute) @@ -710,11 +708,11 @@ class BasicsTest < ActiveRecord::TestCase end def test_boolean - b_nil = Boolean.create({ "value" => nil }) + b_nil = Boolean.create("value" => nil) nil_id = b_nil.id - b_false = Boolean.create({ "value" => false }) + b_false = Boolean.create("value" => false) false_id = b_false.id - b_true = Boolean.create({ "value" => true }) + b_true = Boolean.create("value" => true) true_id = b_true.id b_nil = Boolean.find(nil_id) @@ -726,7 +724,7 @@ class BasicsTest < ActiveRecord::TestCase end def test_boolean_without_questionmark - b_true = Boolean.create({ "value" => true }) + b_true = Boolean.create("value" => true) true_id = b_true.id subclass = Class.new(Boolean).find true_id @@ -736,11 +734,11 @@ class BasicsTest < ActiveRecord::TestCase end def test_boolean_cast_from_string - b_blank = Boolean.create({ "value" => "" }) + b_blank = Boolean.create("value" => "") blank_id = b_blank.id - b_false = Boolean.create({ "value" => "0" }) + b_false = Boolean.create("value" => "0") false_id = b_false.id - b_true = Boolean.create({ "value" => "1" }) + b_true = Boolean.create("value" => "1") true_id = b_true.id b_blank = Boolean.find(blank_id) diff --git a/activerecord/test/cases/connection_specification/resolver_test.rb b/activerecord/test/cases/connection_specification/resolver_test.rb index 7a6125d81b..4bfec47124 100644 --- a/activerecord/test/cases/connection_specification/resolver_test.rb +++ b/activerecord/test/cases/connection_specification/resolver_test.rb @@ -126,7 +126,7 @@ module ActiveRecord end def test_spec_name_with_inline_config - spec = spec({"adapter" => "sqlite3"}) + spec = spec("adapter" => "sqlite3") assert_equal "primary", spec.name, "should default to primary id" end end diff --git a/activerecord/test/cases/date_test.rb b/activerecord/test/cases/date_test.rb index e8a86d0e33..2edc0415cd 100644 --- a/activerecord/test/cases/date_test.rb +++ b/activerecord/test/cases/date_test.rb @@ -31,7 +31,7 @@ class DateTest < ActiveRecord::TestCase invalid_dates.each do |date_src| assert_nothing_raised do - topic = Topic.new({"last_read(1i)" => date_src[0].to_s, "last_read(2i)" => date_src[1].to_s, "last_read(3i)" => date_src[2].to_s}) + topic = Topic.new("last_read(1i)" => date_src[0].to_s, "last_read(2i)" => date_src[1].to_s, "last_read(3i)" => date_src[2].to_s) # Oracle DATE columns are datetime columns and Oracle adapter returns Time value if current_adapter?(:OracleAdapter) assert_equal(topic.last_read.to_date, Time.local(*date_src).to_date, "The date should be modified according to the behavior of the Time object") diff --git a/activerecord/test/cases/log_subscriber_test.rb b/activerecord/test/cases/log_subscriber_test.rb index c594616aa3..8a10399ec2 100644 --- a/activerecord/test/cases/log_subscriber_test.rb +++ b/activerecord/test/cases/log_subscriber_test.rb @@ -103,7 +103,7 @@ class LogSubscriberTest < ActiveRecord::TestCase logger.sql(event.new(0, sql: verb.to_s)) assert_match(/#{REGEXP_BOLD}#{REGEXP_MAGENTA} \(0.0ms\)#{REGEXP_CLEAR}/i, logger.debugs.last) - logger.sql(event.new(0, {sql: verb.to_s, name: "SQL"})) + logger.sql(event.new(0, sql: verb.to_s, name: "SQL")) assert_match(/#{REGEXP_BOLD}#{REGEXP_MAGENTA}SQL \(0.0ms\)#{REGEXP_CLEAR}/i, logger.debugs.last) end end @@ -113,13 +113,13 @@ class LogSubscriberTest < ActiveRecord::TestCase logger = TestDebugLogSubscriber.new logger.colorize_logging = true SQL_COLORINGS.each do |verb, _| - logger.sql(event.new(0, {sql: verb.to_s, name: "Model Load"})) + logger.sql(event.new(0, sql: verb.to_s, name: "Model Load")) assert_match(/#{REGEXP_BOLD}#{REGEXP_CYAN}Model Load \(0.0ms\)#{REGEXP_CLEAR}/i, logger.debugs.last) - logger.sql(event.new(0, {sql: verb.to_s, name: "Model Exists"})) + logger.sql(event.new(0, sql: verb.to_s, name: "Model Exists")) assert_match(/#{REGEXP_BOLD}#{REGEXP_CYAN}Model Exists \(0.0ms\)#{REGEXP_CLEAR}/i, logger.debugs.last) - logger.sql(event.new(0, {sql: verb.to_s, name: "ANY SPECIFIC NAME"})) + logger.sql(event.new(0, sql: verb.to_s, name: "ANY SPECIFIC NAME")) assert_match(/#{REGEXP_BOLD}#{REGEXP_CYAN}ANY SPECIFIC NAME \(0.0ms\)#{REGEXP_CLEAR}/i, logger.debugs.last) end end diff --git a/activerecord/test/cases/migration/change_table_test.rb b/activerecord/test/cases/migration/change_table_test.rb index 045c18eb3f..87da9c90fe 100644 --- a/activerecord/test/cases/migration/change_table_test.rb +++ b/activerecord/test/cases/migration/change_table_test.rb @@ -95,7 +95,7 @@ module ActiveRecord def test_remove_timestamps_creates_updated_at_and_created_at with_change_table do |t| @connection.expect :remove_timestamps, nil, [:delete_me, { null: true }] - t.remove_timestamps({ null: true }) + t.remove_timestamps(null: true) end end diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 61c754fc0e..d3d6931ea4 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -918,7 +918,7 @@ class CopyMigrationsTest < ActiveRecord::TestCase @migrations_path = MIGRATIONS_ROOT + "/valid" @existing_migrations = Dir[@migrations_path + "/*.rb"] - copied = ActiveRecord::Migration.copy(@migrations_path, {bukkits: MIGRATIONS_ROOT + "/to_copy"}) + copied = ActiveRecord::Migration.copy(@migrations_path, bukkits: MIGRATIONS_ROOT + "/to_copy") assert File.exist?(@migrations_path + "/4_people_have_hobbies.bukkits.rb") assert File.exist?(@migrations_path + "/5_people_have_descriptions.bukkits.rb") assert_equal [@migrations_path + "/4_people_have_hobbies.bukkits.rb", @migrations_path + "/5_people_have_descriptions.bukkits.rb"], copied.map(&:filename) @@ -927,7 +927,7 @@ class CopyMigrationsTest < ActiveRecord::TestCase assert_equal expected, IO.readlines(@migrations_path + "/4_people_have_hobbies.bukkits.rb")[0].chomp files_count = Dir[@migrations_path + "/*.rb"].length - copied = ActiveRecord::Migration.copy(@migrations_path, {bukkits: MIGRATIONS_ROOT + "/to_copy"}) + copied = ActiveRecord::Migration.copy(@migrations_path, bukkits: MIGRATIONS_ROOT + "/to_copy") assert_equal files_count, Dir[@migrations_path + "/*.rb"].length assert copied.empty? ensure @@ -960,7 +960,7 @@ class CopyMigrationsTest < ActiveRecord::TestCase @existing_migrations = Dir[@migrations_path + "/*.rb"] travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do - copied = ActiveRecord::Migration.copy(@migrations_path, {bukkits: MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) + copied = ActiveRecord::Migration.copy(@migrations_path, bukkits: MIGRATIONS_ROOT + "/to_copy_with_timestamps") assert File.exist?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb") assert File.exist?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb") expected = [@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb", @@ -968,7 +968,7 @@ class CopyMigrationsTest < ActiveRecord::TestCase assert_equal expected, copied.map(&:filename) files_count = Dir[@migrations_path + "/*.rb"].length - copied = ActiveRecord::Migration.copy(@migrations_path, {bukkits: MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) + copied = ActiveRecord::Migration.copy(@migrations_path, bukkits: MIGRATIONS_ROOT + "/to_copy_with_timestamps") assert_equal files_count, Dir[@migrations_path + "/*.rb"].length assert copied.empty? end @@ -1005,12 +1005,12 @@ class CopyMigrationsTest < ActiveRecord::TestCase @existing_migrations = Dir[@migrations_path + "/*.rb"] travel_to(Time.utc(2010, 2, 20, 10, 10, 10)) do - ActiveRecord::Migration.copy(@migrations_path, {bukkits: MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) + ActiveRecord::Migration.copy(@migrations_path, bukkits: MIGRATIONS_ROOT + "/to_copy_with_timestamps") assert File.exist?(@migrations_path + "/20100301010102_people_have_hobbies.bukkits.rb") assert File.exist?(@migrations_path + "/20100301010103_people_have_descriptions.bukkits.rb") files_count = Dir[@migrations_path + "/*.rb"].length - copied = ActiveRecord::Migration.copy(@migrations_path, {bukkits: MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) + copied = ActiveRecord::Migration.copy(@migrations_path, bukkits: MIGRATIONS_ROOT + "/to_copy_with_timestamps") assert_equal files_count, Dir[@migrations_path + "/*.rb"].length assert copied.empty? end @@ -1023,7 +1023,7 @@ class CopyMigrationsTest < ActiveRecord::TestCase @migrations_path = MIGRATIONS_ROOT + "/valid" @existing_migrations = Dir[@migrations_path + "/*.rb"] - copied = ActiveRecord::Migration.copy(@migrations_path, {bukkits: MIGRATIONS_ROOT + "/magic"}) + copied = ActiveRecord::Migration.copy(@migrations_path, bukkits: MIGRATIONS_ROOT + "/magic") assert File.exist?(@migrations_path + "/4_currencies_have_symbols.bukkits.rb") assert_equal [@migrations_path + "/4_currencies_have_symbols.bukkits.rb"], copied.map(&:filename) @@ -1031,7 +1031,7 @@ class CopyMigrationsTest < ActiveRecord::TestCase assert_equal expected, IO.readlines(@migrations_path + "/4_currencies_have_symbols.bukkits.rb")[0..1].join.chomp files_count = Dir[@migrations_path + "/*.rb"].length - copied = ActiveRecord::Migration.copy(@migrations_path, {bukkits: MIGRATIONS_ROOT + "/magic"}) + copied = ActiveRecord::Migration.copy(@migrations_path, bukkits: MIGRATIONS_ROOT + "/magic") assert_equal files_count, Dir[@migrations_path + "/*.rb"].length assert copied.empty? ensure @@ -1080,7 +1080,7 @@ class CopyMigrationsTest < ActiveRecord::TestCase @existing_migrations = [] travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do - copied = ActiveRecord::Migration.copy(@migrations_path, {bukkits: MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) + copied = ActiveRecord::Migration.copy(@migrations_path, bukkits: MIGRATIONS_ROOT + "/to_copy_with_timestamps") assert File.exist?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb") assert File.exist?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb") assert_equal 2, copied.length @@ -1095,7 +1095,7 @@ class CopyMigrationsTest < ActiveRecord::TestCase @existing_migrations = [] travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do - copied = ActiveRecord::Migration.copy(@migrations_path, {bukkits: MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) + copied = ActiveRecord::Migration.copy(@migrations_path, bukkits: MIGRATIONS_ROOT + "/to_copy_with_timestamps") assert File.exist?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb") assert File.exist?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb") assert_equal 2, copied.length diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb index d1ff270b07..d3923173a7 100644 --- a/activerecord/test/cases/nested_attributes_test.rb +++ b/activerecord/test/cases/nested_attributes_test.rb @@ -119,7 +119,7 @@ class TestNestedAttributesInGeneral < ActiveRecord::TestCase Pirate.accepts_nested_attributes_for :ship, reject_if: proc {|attributes| true } pirate = Pirate.new(catchphrase: "Stop wastin' me time") ship = pirate.create_ship(name: "s1") - pirate.update({ship_attributes: { name: "s2", id: ship.id } }) + pirate.update(ship_attributes: { name: "s2", id: ship.id }) assert_equal "s1", ship.reload.name end @@ -141,7 +141,7 @@ class TestNestedAttributesInGeneral < ActiveRecord::TestCase Man.accepts_nested_attributes_for :interests, reject_if: proc {|attributes| true } man = Man.create(name: "John") interest = man.interests.create(topic: "photography") - man.update({interests_attributes: { topic: "gardening", id: interest.id } }) + man.update(interests_attributes: { topic: "gardening", id: interest.id }) assert_equal "photography", interest.reload.topic end @@ -149,7 +149,7 @@ class TestNestedAttributesInGeneral < ActiveRecord::TestCase Man.accepts_nested_attributes_for :interests, reject_if: proc {|attributes| true }, allow_destroy: true man = Man.create(name: "Jon") interest = man.interests.create(topic: "the ladies") - man.update({interests_attributes: { _destroy: "1", id: interest.id } }) + man.update(interests_attributes: { _destroy: "1", id: interest.id }) assert man.reload.interests.empty? end @@ -170,7 +170,7 @@ class TestNestedAttributesInGeneral < ActiveRecord::TestCase Man.accepts_nested_attributes_for(:interests) man = Man.create(name: "John") interest = man.interests.create(topic: "photography") - man.update({interests_attributes: {topic: "gardening", id: interest.id}}) + man.update(interests_attributes: {topic: "gardening", id: interest.id}) assert_equal "gardening", interest.reload.topic end @@ -338,7 +338,7 @@ class TestNestedAttributesOnAHasOneAssociation < ActiveRecord::TestCase end def test_should_work_with_update_as_well - @pirate.update({ catchphrase: "Arr", ship_attributes: { id: @ship.id, name: "Mister Pablo" } }) + @pirate.update(catchphrase: "Arr", ship_attributes: { id: @ship.id, name: "Mister Pablo" }) @pirate.reload assert_equal "Arr", @pirate.catchphrase @@ -525,7 +525,7 @@ class TestNestedAttributesOnABelongsToAssociation < ActiveRecord::TestCase end def test_should_work_with_update_as_well - @ship.update({ name: "Mister Pablo", pirate_attributes: { catchphrase: "Arr" } }) + @ship.update(name: "Mister Pablo", pirate_attributes: { catchphrase: "Arr" }) @ship.reload assert_equal "Mister Pablo", @ship.name @@ -597,10 +597,8 @@ module NestedAttributesOnACollectionAssociationTests end def test_should_save_only_one_association_on_create - pirate = Pirate.create!({ - :catchphrase => "Arr", - association_getter => { "foo" => { name: "Grace OMalley" } } - }) + pirate = Pirate.create!( :catchphrase => "Arr", + association_getter => { "foo" => { name: "Grace OMalley" } }) assert_equal 1, pirate.reload.send(@association_name).count end @@ -714,7 +712,7 @@ module NestedAttributesOnACollectionAssociationTests def test_should_not_assign_destroy_key_to_a_record assert_nothing_raised do - @pirate.send(association_setter, { "foo" => { "_destroy" => "0" }}) + @pirate.send(association_setter, "foo" => { "_destroy" => "0" }) end end @@ -835,7 +833,7 @@ module NestedAttributesOnACollectionAssociationTests man = Man.create(name: "John") interest = man.interests.create(topic: "bar", zine_id: 0) assert interest.save - assert !man.update({interests_attributes: { id: interest.id, zine_id: "foo" }}) + assert !man.update(interests_attributes: { id: interest.id, zine_id: "foo" }) end end diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb index 1dbf4fcdd6..57dc963b62 100644 --- a/activerecord/test/cases/persistence_test.rb +++ b/activerecord/test/cases/persistence_test.rb @@ -622,7 +622,7 @@ class PersistenceTest < ActiveRecord::TestCase def test_update_columns topic = Topic.find(1) - topic.update_columns({ "approved" => true, title: "Sebastian Topic" }) + topic.update_columns("approved" => true, title: "Sebastian Topic") assert topic.approved? assert_equal "Sebastian Topic", topic.title topic.reload @@ -643,19 +643,19 @@ class PersistenceTest < ActiveRecord::TestCase def test_update_columns_should_raise_exception_if_new_record topic = Topic.new - assert_raises(ActiveRecord::ActiveRecordError) { topic.update_columns({ approved: false }) } + assert_raises(ActiveRecord::ActiveRecordError) { topic.update_columns(approved: false) } end def test_update_columns_should_not_leave_the_object_dirty topic = Topic.find(1) - topic.update({ "content" => "--- Have a nice day\n...\n", :author_name => "Jose" }) + topic.update("content" => "--- Have a nice day\n...\n", :author_name => "Jose") topic.reload - topic.update_columns({ content: "--- You too\n...\n", "author_name" => "Sebastian" }) + topic.update_columns(content: "--- You too\n...\n", "author_name" => "Sebastian") assert_equal [], topic.changed topic.reload - topic.update_columns({ content: "--- Have a nice day\n...\n", author_name: "Jose" }) + topic.update_columns(content: "--- Have a nice day\n...\n", author_name: "Jose") assert_equal [], topic.changed end @@ -671,7 +671,7 @@ class PersistenceTest < ActiveRecord::TestCase minivan = Minivan.find("m1") prev_color = minivan.color prev_name = minivan.name - assert_raises(ActiveRecord::ActiveRecordError) { minivan.update_columns({ name: "My old minivan", color: "black" }) } + assert_raises(ActiveRecord::ActiveRecordError) { minivan.update_columns(name: "My old minivan", color: "black") } assert_equal prev_color, minivan.color assert_equal prev_name, minivan.name @@ -967,11 +967,9 @@ class PersistenceTest < ActiveRecord::TestCase self.table_name = :widgets end - instance = widget.create!({ - name: "Bob", + instance = widget.create!( name: "Bob", created_at: 1.day.ago, - updated_at: 1.day.ago - }) + updated_at: 1.day.ago) created_at = instance.created_at updated_at = instance.updated_at diff --git a/activerecord/test/cases/pooled_connections_test.rb b/activerecord/test/cases/pooled_connections_test.rb index 71fc0881c1..f200770562 100644 --- a/activerecord/test/cases/pooled_connections_test.rb +++ b/activerecord/test/cases/pooled_connections_test.rb @@ -18,7 +18,7 @@ class PooledConnectionsTest < ActiveRecord::TestCase # Will deadlock due to lack of Monitor timeouts in 1.9 def checkout_checkin_connections(pool_size, threads) - ActiveRecord::Base.establish_connection(@connection.merge({pool: pool_size, checkout_timeout: 0.5})) + ActiveRecord::Base.establish_connection(@connection.merge(pool: pool_size, checkout_timeout: 0.5)) @connection_count = 0 @timed_out = 0 threads.times do @@ -36,7 +36,7 @@ class PooledConnectionsTest < ActiveRecord::TestCase end def checkout_checkin_connections_loop(pool_size, loops) - ActiveRecord::Base.establish_connection(@connection.merge({pool: pool_size, checkout_timeout: 0.5})) + ActiveRecord::Base.establish_connection(@connection.merge(pool: pool_size, checkout_timeout: 0.5)) @connection_count = 0 @timed_out = 0 loops.times do @@ -66,7 +66,7 @@ class PooledConnectionsTest < ActiveRecord::TestCase end def test_pooled_connection_remove - ActiveRecord::Base.establish_connection(@connection.merge({pool: 2, checkout_timeout: 0.5})) + ActiveRecord::Base.establish_connection(@connection.merge(pool: 2, checkout_timeout: 0.5)) old_connection = ActiveRecord::Base.connection extra_connection = ActiveRecord::Base.connection_pool.checkout ActiveRecord::Base.connection_pool.remove(extra_connection) diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index d5aee29102..c9f7f2d542 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -510,7 +510,7 @@ class RelationTest < ActiveRecord::TestCase end def test_finding_with_hash_conditions_on_joined_table - firms = DependentFirm.joins(:account).where({name: "RailsCore", accounts: { credit_limit: 55..60 }}).to_a + firms = DependentFirm.joins(:account).where(name: "RailsCore", accounts: { credit_limit: 55..60 }).to_a assert_equal 1, firms.size assert_equal companies(:rails_core), firms.first end @@ -526,7 +526,7 @@ class RelationTest < ActiveRecord::TestCase end def test_find_on_hash_conditions - assert_equal Topic.all.merge!(where: {approved: false}).to_a, Topic.where({ approved: false }).to_a + assert_equal Topic.all.merge!(where: {approved: false}).to_a, Topic.where(approved: false).to_a end def test_joins_with_string_array diff --git a/activerecord/test/cases/sanitize_test.rb b/activerecord/test/cases/sanitize_test.rb index fc7a653557..464bb12ccb 100644 --- a/activerecord/test/cases/sanitize_test.rb +++ b/activerecord/test/cases/sanitize_test.rb @@ -97,9 +97,9 @@ class SanitizeTest < ActiveRecord::TestCase end def test_named_bind_arity - assert_nothing_raised { bind "name = :name", { name: "37signals" } } - assert_nothing_raised { bind "name = :name", { name: "37signals", id: 1 } } - assert_raise(ActiveRecord::PreparedStatementInvalid) { bind "name = :name", { id: 1 } } + assert_nothing_raised { bind "name = :name", name: "37signals" } + assert_nothing_raised { bind "name = :name", name: "37signals", id: 1 } + assert_raise(ActiveRecord::PreparedStatementInvalid) { bind "name = :name", id: 1 } end class SimpleEnumerable diff --git a/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb b/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb index d44b22b285..d73d287073 100644 --- a/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb +++ b/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb @@ -56,28 +56,28 @@ class I18nGenerateMessageValidationTest < ActiveRecord::TestCase test "translation for 'taken' can be overridden" do reset_i18n_load_path do - I18n.backend.store_translations "en", {errors: {attributes: {title: {taken: "Custom taken message" }}}} + I18n.backend.store_translations "en", errors: {attributes: {title: {taken: "Custom taken message" }}} assert_equal "Custom taken message", @topic.errors.generate_message(:title, :taken, value: "title") end end test "translation for 'taken' can be overridden in activerecord scope" do reset_i18n_load_path do - I18n.backend.store_translations "en", {activerecord: {errors: {messages: {taken: "Custom taken message" }}}} + I18n.backend.store_translations "en", activerecord: {errors: {messages: {taken: "Custom taken message" }}} assert_equal "Custom taken message", @topic.errors.generate_message(:title, :taken, value: "title") end end test "translation for 'taken' can be overridden in activerecord model scope" do reset_i18n_load_path do - I18n.backend.store_translations "en", {activerecord: {errors: {models: {topic: {taken: "Custom taken message" }}}}} + I18n.backend.store_translations "en", activerecord: {errors: {models: {topic: {taken: "Custom taken message" }}}} assert_equal "Custom taken message", @topic.errors.generate_message(:title, :taken, value: "title") end end test "translation for 'taken' can be overridden in activerecord attributes scope" do reset_i18n_load_path do - I18n.backend.store_translations "en", {activerecord: {errors: {models: {topic: {attributes: {title: {taken: "Custom taken message" }}}}}}} + I18n.backend.store_translations "en", activerecord: {errors: {models: {topic: {attributes: {title: {taken: "Custom taken message" }}}}}} assert_equal "Custom taken message", @topic.errors.generate_message(:title, :taken, value: "title") end end diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb index e019c9a3e1..76510cb80d 100644 --- a/activerecord/test/cases/validations_test.rb +++ b/activerecord/test/cases/validations_test.rb @@ -107,7 +107,7 @@ class ValidationsTest < ActiveRecord::TestCase def test_exception_on_create_bang_with_block assert_raise(ActiveRecord::RecordInvalid) do - WrongReply.create!({ "title" => "OK" }) do |r| + WrongReply.create!("title" => "OK") do |r| r.content = nil end end |