aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/integration_test.rb
diff options
context:
space:
mode:
authorTakehiro Adachi <takehiro0740@gmail.com>2013-05-02 17:31:23 +0900
committerTakehiro Adachi <takehiro0740@gmail.com>2013-05-02 22:16:51 +0900
commitec0566cc91601b45e77d256cbf0cad632a81ec49 (patch)
treedddedc7529c9f824e4314690de943da1ae806a9c /activerecord/test/cases/integration_test.rb
parentdfd5dc93a1ead62353cc33f5065e23b4fdf25b3e (diff)
downloadrails-ec0566cc91601b45e77d256cbf0cad632a81ec49.tar.gz
rails-ec0566cc91601b45e77d256cbf0cad632a81ec49.tar.bz2
rails-ec0566cc91601b45e77d256cbf0cad632a81ec49.zip
Add test for `AR::Base#to_param`
According to the doc of `AR::Base#to_param`( https://github.com/rails/rails/blob/04cda1848cb847c2bdad0bfc12160dc8d554 7775/activerecord/lib/active_record/integration.rb#L18 ), it returns `nil` if the record is not persisted.
Diffstat (limited to 'activerecord/test/cases/integration_test.rb')
-rw-r--r--activerecord/test/cases/integration_test.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/test/cases/integration_test.rb b/activerecord/test/cases/integration_test.rb
index 7fbde4e2f9..b0a7cda2f3 100644
--- a/activerecord/test/cases/integration_test.rb
+++ b/activerecord/test/cases/integration_test.rb
@@ -11,7 +11,12 @@ class IntegrationTest < ActiveRecord::TestCase
assert_kind_of String, Client.first.to_param
end
- def test_to_param_returns_id_even_if_not_persisted
+ def test_to_param_returns_nil_if_not_persisted
+ client = Client.new
+ assert_equal nil, client.to_param
+ end
+
+ def test_to_param_returns_id_if_not_persisted_but_id_is_set
client = Client.new
client.id = 1
assert_equal '1', client.to_param