diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2012-09-20 11:19:47 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2012-09-20 11:19:47 -0700 |
commit | 0a7b1319d35371d4ccf8ed3217f4c57c81225dd7 (patch) | |
tree | 28d1b17139852ea57b66c215fe115154a3f55302 /activesupport/test | |
parent | 81084bda1d39f3126235b564487fdb10504f0f48 (diff) | |
parent | ad5f18e6e936e783e0e97a9315ed4a72f333a2cd (diff) | |
download | rails-0a7b1319d35371d4ccf8ed3217f4c57c81225dd7.tar.gz rails-0a7b1319d35371d4ccf8ed3217f4c57c81225dd7.tar.bz2 rails-0a7b1319d35371d4ccf8ed3217f4c57c81225dd7.zip |
Merge pull request #7613 from marcandre/delegate_to_class
Nice and easy delegation to the class
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/module_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index bd41311739..82249ddd1b 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -34,6 +34,12 @@ class Someone < Struct.new(:name, :place) delegate :street, :city, :to_f, :to => :place delegate :name=, :to => :place, :prefix => true delegate :upcase, :to => "place.city" + delegate :table_name, :to => :class + delegate :table_name, :to => :class, :prefix => true + + def self.table_name + 'some_table' + end FAILED_DELEGATE_LINE = __LINE__ + 1 delegate :foo, :to => :place @@ -111,6 +117,11 @@ class ModuleTest < ActiveSupport::TestCase assert_equal "DAVID HANSSON", david.upcase end + def test_delegation_to_class_method + assert_equal 'some_table', @david.table_name + assert_equal 'some_table', @david.class_table_name + end + def test_missing_delegation_target assert_raise(ArgumentError) do Name.send :delegate, :nowhere |