rails/rails — pull request #18130 by claudiob (2014-12-22 03:07:52+00:00)
Title: Better docs and tests for AV::RecordIdentifier

This commit intends to clarify the scope of ActionView::RecordIdentifier methods `dom_id` and `dom_class`.

Most of the current documentation comes from da257eb8 (7 years ago) when the decoupling of ActionView, ActiveRecord and ActiveModel was not a concern.

Since then, steps have been taken to reach such decoupling, especially 8ca17926 which duplicated ActionController::ModelNaming into ActionView::ModelNaming explaining that:

> These are just a simple helpers for decoupling Active Model, so it does not
> make sense to extract it to Active Support, but the point is to decouple also
> Action View and Action Pack

As of today, ActionView::RecordIdentifier only includes `dom_id` and `dom_class` so it makes sense to explicitly document those two methods and to leave the details of helpers like `div_for` in the corresponding files.

Moreover, I think it's important to mention in the documentation that ActionView::RecordIdentifier **does not strictly depend on ActiveRecord::Base**: any class `Post` implementing `post.to_key` and `post.model_name.param_key` will work.

This commit improves the documentation in this sense, and adds a test to prove that ActionView::RecordIdentifier methods can also be used on objects that do not subclass ActiveRecord::Base.

/cc @fxn