diff options
author | claudiob <claudiob@gmail.com> | 2014-12-19 12:49:50 -0800 |
---|---|---|
committer | claudiob <claudiob@gmail.com> | 2014-12-23 01:59:25 +0100 |
commit | b26338e83b4249ede5ea1368498b4dbf31b44612 (patch) | |
tree | 1f79cd684fd9c10d4d76d065be09fd4848ed3cf1 /actionview/test/lib/controller | |
parent | 8259d795606e3f3333537baadf0d1a37c4fd4fd0 (diff) | |
download | rails-b26338e83b4249ede5ea1368498b4dbf31b44612.tar.gz rails-b26338e83b4249ede5ea1368498b4dbf31b44612.tar.bz2 rails-b26338e83b4249ede5ea1368498b4dbf31b44612.zip |
Better 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.
Therefore I think it's important to show that ActionView::RecordIdentifier
**does not strictly depend on the ActiveRecord API**:
any class `Post` implementing `post.to_key` and `post.model_name.param_key`
will work.
This commit adds a test to prove that ActionView::RecordIdentifier methods
can also be used on objects that do not subclass ActiveRecord::Base.
Diffstat (limited to 'actionview/test/lib/controller')
-rw-r--r-- | actionview/test/lib/controller/fake_models.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/actionview/test/lib/controller/fake_models.rb b/actionview/test/lib/controller/fake_models.rb index cb02a56cb4..789b1d198b 100644 --- a/actionview/test/lib/controller/fake_models.rb +++ b/actionview/test/lib/controller/fake_models.rb @@ -170,3 +170,15 @@ end class Car < Struct.new(:color) end + +class Plane + attr_reader :to_key + + def model_name + OpenStruct.new param_key: 'airplane' + end + + def save + @to_key = [1] + end +end |