aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/lint.rb23
-rw-r--r--activemodel/lib/active_model/naming.rb2
2 files changed, 24 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/lint.rb b/activemodel/lib/active_model/lint.rb
index 7bf0ad712d..c97286e61c 100644
--- a/activemodel/lib/active_model/lint.rb
+++ b/activemodel/lib/active_model/lint.rb
@@ -13,6 +13,29 @@
module ActiveModel
module Lint
module Tests
+
+ # == Responds to <tt>key</tt>
+ #
+ # Returns an Enumerable of all (primary) key attributes
+ # or nil if model.new_record? is true
+ def test_key
+ assert model.respond_to?(:key), "The model should respond to key"
+ def model.new_record?() true end
+ assert model.key.nil?
+ def model.new_record?() false end
+ assert model.key.respond_to?(:each)
+ end
+
+ # == Responds to <tt>to_param</tt>
+ #
+ # Returns a string representing the object's key suitable for use in URLs
+ # or nil if model.new_record? is true
+ def test_to_param
+ assert model.respond_to?(:to_param), "The model should respond to to_param"
+ def model.new_record?() true end
+ assert model.to_param.nil?
+ end
+
# == Responds to <tt>valid?</tt>
#
# Returns a boolean that specifies whether the object is in a valid or invalid
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb
index 89e8f8b1ea..39512a427b 100644
--- a/activemodel/lib/active_model/naming.rb
+++ b/activemodel/lib/active_model/naming.rb
@@ -41,7 +41,7 @@ module ActiveModel
# To implement, just extend ActiveModel::Naming in your object:
#
# class BookCover
- # exten ActiveModel::Naming
+ # extend ActiveModel::Naming
# end
#
# BookCover.model_name #=> "BookCover"