From 633100b9e5ab0ca634c86eb56bc2da4f3b33e8c4 Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Thu, 14 Nov 2013 15:02:05 -0500 Subject: Addendum to #12891 * Fix incorrectly named tests * Restore Object#to_param behavior * Ensure param is derived from a squished and truncated string --- activerecord/test/cases/integration_test.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/integration_test.rb b/activerecord/test/cases/integration_test.rb index 1f62433ea2..8097f6e36e 100644 --- a/activerecord/test/cases/integration_test.rb +++ b/activerecord/test/cases/integration_test.rb @@ -28,7 +28,19 @@ class IntegrationTest < ActiveRecord::TestCase assert_equal '4-flamboyant-software', firm.to_param end - def to_param_class_method_uses_default_if_blank + def test_to_param_class_method_truncates + firm = Firm.find(4) + firm.name = 'a ' * 100 + assert_equal '4-a-a-a-a-a-a-a-a-a', firm.to_param + end + + def test_to_param_class_method_squishes + firm = Firm.find(4) + firm.name = "ab \n" * 100 + assert_equal '4-ab-ab-ab-ab-ab-ab', firm.to_param + end + + def test_to_param_class_method_uses_default_if_blank firm = Firm.find(4) firm.name = nil assert_equal '4', firm.to_param @@ -36,11 +48,15 @@ class IntegrationTest < ActiveRecord::TestCase assert_equal '4', firm.to_param end - def to_param_class_method_uses_default_if_not_persisted + def test_to_param_class_method_uses_default_if_not_persisted firm = Firm.new(name: 'Fancy Shirts') assert_equal nil, firm.to_param end + def test_to_param_with_no_arguments + assert_equal 'Firm', Firm.to_param + end + def test_cache_key_for_existing_record_is_not_timezone_dependent utc_key = Developer.first.cache_key -- cgit v1.2.3