diff options
Diffstat (limited to 'activerecord/test/cases/base_test.rb')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index d326ed7863..4f46459ab3 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -26,7 +26,6 @@ require 'models/bird' require 'models/car' require 'models/bulb' require 'rexml/document' -require 'active_support/core_ext/exception' class FirstAbstractClass < ActiveRecord::Base self.abstract_class = true @@ -125,7 +124,7 @@ class BasicsTest < ActiveRecord::TestCase assert_nil Edge.primary_key end - unless current_adapter?(:PostgreSQLAdapter,:OracleAdapter,:SQLServerAdapter) + unless current_adapter?(:PostgreSQLAdapter, :OracleAdapter, :SQLServerAdapter) def test_limit_with_comma assert Topic.limit("1,2").to_a end @@ -154,7 +153,7 @@ class BasicsTest < ActiveRecord::TestCase end end - unless current_adapter?(:MysqlAdapter) || current_adapter?(:Mysql2Adapter) + unless current_adapter?(:MysqlAdapter, :Mysql2Adapter) def test_limit_should_allow_sql_literal assert_equal 1, Topic.limit(Arel.sql('2-1')).to_a.length end @@ -223,7 +222,7 @@ class BasicsTest < ActiveRecord::TestCase ) # For adapters which support microsecond resolution. - if current_adapter?(:PostgreSQLAdapter) || current_adapter?(:SQLite3Adapter) + if current_adapter?(:PostgreSQLAdapter, :SQLite3Adapter) assert_equal 11, Topic.find(1).written_on.sec assert_equal 223300, Topic.find(1).written_on.usec assert_equal 9900, Topic.find(2).written_on.usec @@ -301,13 +300,11 @@ class BasicsTest < ActiveRecord::TestCase end def test_initialize_with_invalid_attribute - begin - 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) - end + 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) end def test_create_after_initialize_without_block @@ -472,7 +469,7 @@ class BasicsTest < ActiveRecord::TestCase Post.reset_table_name end - if current_adapter?(:MysqlAdapter) or current_adapter?(:Mysql2Adapter) + if current_adapter?(:MysqlAdapter, :Mysql2Adapter) def test_update_all_with_order_and_limit assert_equal 1, Topic.limit(1).order('id DESC').update_all(:content => 'bulk updated!') end @@ -594,7 +591,7 @@ class BasicsTest < ActiveRecord::TestCase post.reload assert_equal "cannot change this", post.title - post.update_attributes(:title => "try to change", :body => "changed") + post.update(title: "try to change", body: "changed") post.reload assert_equal "cannot change this", post.title assert_equal "changed", post.body @@ -1002,7 +999,7 @@ class BasicsTest < ActiveRecord::TestCase def test_reload_with_exclusive_scope dev = DeveloperCalledDavid.first - dev.update_attributes!( :name => "NotDavid" ) + dev.update!(name: "NotDavid" ) assert_equal dev, dev.reload end @@ -1484,7 +1481,7 @@ class BasicsTest < ActiveRecord::TestCase def test_column_types_typecast topic = Topic.first - refute_equal 't.lo', topic.author_name + assert_not_equal 't.lo', topic.author_name attrs = topic.attributes.dup attrs.delete 'id' |