module ActiveModel::Lint::Tests
def test_to_param
tests for this behavior in lint because it doesn't make sense to force
default in case the record uses a composite primary key. There are no
Implementers can decide to either raise an exception or provide a
to_param is used to represent the object's key in URLs.
Fails otherwise.
calling this method returns +nil+ when the object is not persisted.
Passes if the object's model responds to to_param and if
def test_to_param assert_respond_to model, :to_param def model.to_key() [1] end def model.persisted?() false end assert model.to_param.nil?, "to_param should return nil when `persisted?` returns false" end