diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-07 14:26:57 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-07 14:26:57 +0000 |
commit | 1aa82b3217d243c3074feb47baed07a620a270e2 (patch) | |
tree | 00a97c08a850ad990e1b80817d58e6f4fb6547ca /activerecord/test | |
parent | b8e4c78abba471ec3bcce29237644df24925d1a7 (diff) | |
download | rails-1aa82b3217d243c3074feb47baed07a620a270e2.tar.gz rails-1aa82b3217d243c3074feb47baed07a620a270e2.tar.bz2 rails-1aa82b3217d243c3074feb47baed07a620a270e2.zip |
Added keyword-style approach to defining the custom relational bindings #545 [Jamis Buck]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@527 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/base_test.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index c1f9a77638..b232949a25 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -706,4 +706,58 @@ class BasicsTest < Test::Unit::TestCase t2.reload assert_equal t1.title, t2.title end + + def test_define_attr_method_with_value + k = Class.new( ActiveRecord::Base ) + k.define_attr_method :table_name, "foo" + assert_equal "foo", k.table_name + end + + def test_define_attr_method_with_block + k = Class.new( ActiveRecord::Base ) + k.define_attr_method( :primary_key ) { "sys_" + original_primary_key } + assert_equal "sys_id", k.primary_key + end + + def test_set_table_name_with_value + k = Class.new( ActiveRecord::Base ) + k.table_name = "foo" + assert_equal "foo", k.table_name + k.set_table_name "bar" + assert_equal "bar", k.table_name + end + + def test_set_table_name_with_block + k = Class.new( ActiveRecord::Base ) + k.set_table_name { "ks" } + assert_equal "ks", k.table_name + end + + def test_set_primary_key_with_value + k = Class.new( ActiveRecord::Base ) + k.primary_key = "foo" + assert_equal "foo", k.primary_key + k.set_primary_key "bar" + assert_equal "bar", k.primary_key + end + + def test_set_primary_key_with_block + k = Class.new( ActiveRecord::Base ) + k.set_primary_key { "sys_" + original_primary_key } + assert_equal "sys_id", k.primary_key + end + + def test_set_inheritance_column_with_value + k = Class.new( ActiveRecord::Base ) + k.inheritance_column = "foo" + assert_equal "foo", k.inheritance_column + k.set_inheritance_column "bar" + assert_equal "bar", k.inheritance_column + end + + def test_set_inheritance_column_with_block + k = Class.new( ActiveRecord::Base ) + k.set_inheritance_column { original_inheritance_column + "_id" } + assert_equal "type_id", k.inheritance_column + end end |