From 2ed6d365bbb2a3e0138add33be964d1cc1705b76 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 19 Nov 2005 09:53:36 +0000 Subject: Correct boolean handling in generated reader methods. References #2945. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3092 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/abstract_unit.rb | 3 +++ activerecord/test/base_test.rb | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/abstract_unit.rb b/activerecord/test/abstract_unit.rb index 0626243521..d9c60ab6bd 100755 --- a/activerecord/test/abstract_unit.rb +++ b/activerecord/test/abstract_unit.rb @@ -24,3 +24,6 @@ def current_adapter?(type) ActiveRecord::ConnectionAdapters.const_defined?(type) && ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters.const_get(type)) end + +#ActiveRecord::Base.logger = Logger.new(STDOUT) +#ActiveRecord::Base.colorize_logging = false diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index 1ad6e6c3ee..c819c97f3b 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -206,6 +206,40 @@ class BasicsTest < Test::Unit::TestCase topic = topics(:first) topic.approved = false assert !topic.approved?, "approved should be false" + topic.approved = "false" + assert !topic.approved?, "approved should be false" + end + + def test_read_attribute_when_true + topic = topics(:first) + topic.approved = true + assert topic.approved?, "approved should be true" + topic.approved = "true" + assert topic.approved?, "approved should be true" + end + + def test_read_write_boolean_attribute + topic = Topic.new + # puts "" + # puts "New Topic" + # puts topic.inspect + topic.approved = "false" + # puts "Expecting false" + # puts topic.inspect + assert !topic.approved, "approved should be false" + topic.approved = "false" + # puts "Expecting false" + # puts topic.inspect + assert !topic.approved, "approved should be false" + topic.approved = "true" + # puts "Expecting true" + # puts topic.inspect + assert topic.approved, "approved should be true" + topic.approved = "true" + # puts "Expecting true" + # puts topic.inspect + assert topic.approved, "approved should be true" + # puts "" end def test_reader_generation -- cgit v1.2.3