diff options
author | Grant Hutchins & Peter Jaros <pair+grant+pjaros@pivotallabs.com> | 2011-07-08 17:54:15 -0400 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-08-13 16:22:21 -0700 |
commit | 6e671a8536f17b6f23b5251652015ce8c1557f1f (patch) | |
tree | 98177efb062b64203d0b33122515fd7b72909392 /activemodel/lib/active_model/lint.rb | |
parent | a636a9358e184bd1a3e2d2522584247be7045cdf (diff) | |
download | rails-6e671a8536f17b6f23b5251652015ce8c1557f1f.tar.gz rails-6e671a8536f17b6f23b5251652015ce8c1557f1f.tar.bz2 rails-6e671a8536f17b6f23b5251652015ce8c1557f1f.zip |
Let ActiveModel instances define partial paths.
Deprecate ActiveModel::Name#partial_path. Now you
should call #to_path directly on ActiveModel
instances.
Diffstat (limited to 'activemodel/lib/active_model/lint.rb')
-rw-r--r-- | activemodel/lib/active_model/lint.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/lint.rb b/activemodel/lib/active_model/lint.rb index b71ef4b22e..08c2e5fcf3 100644 --- a/activemodel/lib/active_model/lint.rb +++ b/activemodel/lib/active_model/lint.rb @@ -43,6 +43,16 @@ module ActiveModel assert model.to_param.nil?, "to_param should return nil when `persisted?` returns false" end + # == Responds to <tt>to_path</tt> + # + # Returns a string giving a relative path. This is used for looking up + # partials. For example, a BlogPost model might return "blog_posts/blog_post" + # + def test_to_path + assert model.respond_to?(:to_path), "The model should respond to to_path" + assert_kind_of String, model.to_path + end + # == Responds to <tt>valid?</tt> # # Returns a boolean that specifies whether the object is in a valid or invalid @@ -66,15 +76,14 @@ module ActiveModel # == Naming # - # Model.model_name must return a string with some convenience methods as - # :human and :partial_path. Check ActiveModel::Naming for more information. + # Model.model_name must return a string with some convenience methods: + # :human, :singular, and :plural. Check ActiveModel::Naming for more information. # def test_model_naming assert model.class.respond_to?(:model_name), "The model should respond to model_name" model_name = model.class.model_name assert_kind_of String, model_name assert_kind_of String, model_name.human - assert_kind_of String, model_name.partial_path assert_kind_of String, model_name.singular assert_kind_of String, model_name.plural end |