Skip to content

Commit ec0566c

Browse files
committed
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.
1 parent dfd5dc9 commit ec0566c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

activerecord/test/cases/integration_test.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ def test_to_param_should_return_string
1111
assert_kind_of String, Client.first.to_param
1212
end
1313

14-
def test_to_param_returns_id_even_if_not_persisted
14+
def test_to_param_returns_nil_if_not_persisted
15+
client = Client.new
16+
assert_equal nil, client.to_param
17+
end
18+
19+
def test_to_param_returns_id_if_not_persisted_but_id_is_set
1520
client = Client.new
1621
client.id = 1
1722
assert_equal '1', client.to_param

0 commit comments

Comments
 (0)