diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2013-11-14 11:03:31 -0800 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2013-11-14 11:03:31 -0800 |
commit | a23bf6f55a2bea50ec39cc744e17c924d727c089 (patch) | |
tree | c3c14732612183b2fbd4e10b380361d1d1e5f794 /activerecord/test/cases | |
parent | 83a065d181efc5eb1983cdf369bcb96c25fa9c2d (diff) | |
parent | 547999df256a5ac650eb012dabf713027b9bda1f (diff) | |
download | rails-a23bf6f55a2bea50ec39cc744e17c924d727c089.tar.gz rails-a23bf6f55a2bea50ec39cc744e17c924d727c089.tar.bz2 rails-a23bf6f55a2bea50ec39cc744e17c924d727c089.zip |
Merge pull request #12891 from javan/to-param
Add AR::Base.to_param for convenient "pretty" URLs derived from a model's attribute or method
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/integration_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/integration_test.rb b/activerecord/test/cases/integration_test.rb index 840865c4cf..1f62433ea2 100644 --- a/activerecord/test/cases/integration_test.rb +++ b/activerecord/test/cases/integration_test.rb @@ -23,6 +23,24 @@ class IntegrationTest < ActiveRecord::TestCase assert_equal '1', client.to_param end + def test_to_param_class_method + firm = Firm.find(4) + assert_equal '4-flamboyant-software', firm.to_param + end + + def to_param_class_method_uses_default_if_blank + firm = Firm.find(4) + firm.name = nil + assert_equal '4', firm.to_param + firm.name = ' ' + assert_equal '4', firm.to_param + end + + def to_param_class_method_uses_default_if_not_persisted + firm = Firm.new(name: 'Fancy Shirts') + assert_equal nil, firm.to_param + end + def test_cache_key_for_existing_record_is_not_timezone_dependent utc_key = Developer.first.cache_key |