aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-12-31 14:19:30 +0100
committerJosé Valim <jose.valim@gmail.com>2010-01-02 22:27:02 +0100
commit653fa4c10c3e4a34cfe0fe93a2612ed178ca4455 (patch)
treec80c37ef2fccd44e48f400d0aa7541428fff6b81 /activemodel
parent7cc0a4cfa1d18c011d6e41f57d25eb10ed018eba (diff)
downloadrails-653fa4c10c3e4a34cfe0fe93a2612ed178ca4455.tar.gz
rails-653fa4c10c3e4a34cfe0fe93a2612ed178ca4455.tar.bz2
rails-653fa4c10c3e4a34cfe0fe93a2612ed178ca4455.zip
Add naming to AMo::Lint
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/lint.rb14
-rw-r--r--activemodel/test/cases/lint_test.rb2
2 files changed, 16 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/lint.rb b/activemodel/lib/active_model/lint.rb
index 1c2347adbf..0be82aa180 100644
--- a/activemodel/lib/active_model/lint.rb
+++ b/activemodel/lib/active_model/lint.rb
@@ -41,6 +41,20 @@ module ActiveModel
assert_boolean model.destroyed?, "destroyed?"
end
+ # naming
+ # ------
+ #
+ # Model.model_name must returns a string with some convenience methods as
+ # :human and :partial_path. 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
+ end
+
# errors
# ------
#
diff --git a/activemodel/test/cases/lint_test.rb b/activemodel/test/cases/lint_test.rb
index da7d2112dc..63804004ee 100644
--- a/activemodel/test/cases/lint_test.rb
+++ b/activemodel/test/cases/lint_test.rb
@@ -4,6 +4,8 @@ class LintTest < ActiveModel::TestCase
include ActiveModel::Lint::Tests
class CompliantModel
+ extend ActiveModel::Naming
+
def to_model
self
end