diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-29 10:56:33 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-29 10:56:33 -0700 |
commit | 295e91221123b912f2545cdc2e5623aeb53b220f (patch) | |
tree | a41a2591753ceb1c3bb2c242a3461d7fc9a5c75a /activerecord/test | |
parent | 8ed1a562c6293c81c894f3fe55fe88610c4f6caa (diff) | |
parent | 4584be9b8bd15277cc05e8729830247df45d46dc (diff) | |
download | rails-295e91221123b912f2545cdc2e5623aeb53b220f.tar.gz rails-295e91221123b912f2545cdc2e5623aeb53b220f.tar.bz2 rails-295e91221123b912f2545cdc2e5623aeb53b220f.zip |
Merge branch 'master' into mapper
* master:
Update url to rake docs [ci skip]
Name#model_name doesn't return a String object
Result sets never override a model's column type
[ci skip] Make last note show up in postgresql guide.
Add missing `:param` option from the docs for Mapper#match [ci skip] Option discovered by @zackperdue in #14741, implemented in #5581.
Add @senny's changed from #14741, including code font for `resources` options, and wrapped to 80 chars. [ci skip]
Use github url for homepage of log4r [ci skip]
Remove TODO.
Ensure we always use instances of the adapter specific column class
Fix indentation from 1b4b26f [ci skip]
[ci skip] Improve form_helpers.md guide.
Clear inflections after test.
Remove unnecessary include for integration tests.
Added documentation for the :param option for resourceful routing
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/adapters/mysql/consistency_test.rb | 48 | ||||
-rw-r--r-- | activerecord/test/cases/custom_properties_test.rb | 2 |
2 files changed, 50 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/mysql/consistency_test.rb b/activerecord/test/cases/adapters/mysql/consistency_test.rb new file mode 100644 index 0000000000..083d533bb2 --- /dev/null +++ b/activerecord/test/cases/adapters/mysql/consistency_test.rb @@ -0,0 +1,48 @@ +require "cases/helper" + +class MysqlConsistencyTest < ActiveRecord::TestCase + self.use_transactional_fixtures = false + + class Consistency < ActiveRecord::Base + self.table_name = "mysql_consistency" + end + + setup do + @old_emulate_booleans = ActiveRecord::ConnectionAdapters::MysqlAdapter.emulate_booleans + ActiveRecord::ConnectionAdapters::MysqlAdapter.emulate_booleans = false + + @connection = ActiveRecord::Base.connection + @connection.create_table("mysql_consistency") do |t| + t.boolean "a_bool" + t.string "a_string" + end + Consistency.reset_column_information + Consistency.create! + end + + teardown do + ActiveRecord::ConnectionAdapters::MysqlAdapter.emulate_booleans = @old_emulate_booleans + @connection.drop_table "mysql_consistency" + end + + test "boolean columns with random value type cast to 0 when emulate_booleans is false" do + with_new = Consistency.new + with_last = Consistency.last + with_new.a_bool = 'wibble' + with_last.a_bool = 'wibble' + + assert_equal 0, with_new.a_bool + assert_equal 0, with_last.a_bool + end + + test "string columns call #to_s" do + with_new = Consistency.new + with_last = Consistency.last + thing = Object.new + with_new.a_string = thing + with_last.a_string = thing + + assert_equal thing.to_s, with_new.a_string + assert_equal thing.to_s, with_last.a_string + end +end diff --git a/activerecord/test/cases/custom_properties_test.rb b/activerecord/test/cases/custom_properties_test.rb index 397a8e0692..047c1b9b74 100644 --- a/activerecord/test/cases/custom_properties_test.rb +++ b/activerecord/test/cases/custom_properties_test.rb @@ -37,7 +37,9 @@ module ActiveRecord data.reload assert_equal 2, data.overloaded_float + assert_kind_of Fixnum, OverloadedType.last.overloaded_float assert_equal 2.0, UnoverloadedType.last.overloaded_float + assert_kind_of Float, UnoverloadedType.last.overloaded_float end def test_properties_assigned_in_constructor |