Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Deprecated should_only_allow_numeric_values_for in favor of should_va…

…lidate_numericality_of
  • Loading branch information...
commit 5da9cb1dc2241cb5536d5782edc8e9e2b97c17df 1 parent 192d744
@jferris jferris authored
View
11 lib/shoulda/active_record/macros.rb
@@ -304,9 +304,9 @@ def should_ensure_value_in_range(attribute, range, opts = {})
# Regexp or string. Default = <tt>I18n.translate('activerecord.errors.messages.not_a_number')</tt>
#
# Example:
- # should_only_allow_numeric_values_for :age
+ # should_validate_numericality_of :age
#
- def should_only_allow_numeric_values_for(*attributes)
+ def should_validate_numericality_of(*attributes)
message = get_options!(attributes, :message)
klass = model_class
attributes.each do |attribute|
@@ -318,6 +318,13 @@ def should_only_allow_numeric_values_for(*attributes)
end
end
+ # Deprecated. See should_validate_uniqueness_of
+ def should_only_allow_numeric_values_for(*attributes)
+ warn "[DEPRECATION] should_only_allow_numeric_values_for is " <<
+ "deprecated. Use should_validate_numericality_of instead."
+ should_validate_numericality_of(*attributes)
+ end
+
# Ensures that the has_many relationship exists. Will also test that the
# associated table has the required columns. Works with polymorphic
# associations.
View
2  test/unit/post_test.rb
@@ -11,7 +11,7 @@ class PostTest < Test::Unit::TestCase
should_require_unique_attributes :title
should_validate_presence_of :body, :message => /wtf/
should_validate_presence_of :title
- should_only_allow_numeric_values_for :user_id
+ should_validate_numericality_of :user_id
should_fail do
should_validate_uniqueness_of :title, :case_sensitive => false
View
2  test/unit/user_test.rb
@@ -50,7 +50,7 @@ class UserTest < Test::Unit::TestCase
should_validate_uniqueness_of :email, :scoped_to => :name, :case_sensitive => false
should_ensure_length_is :ssn, 9, :message => "Social Security Number is not the right length"
- should_only_allow_numeric_values_for :ssn
+ should_validate_numericality_of :ssn
should_have_readonly_attributes :name
Please sign in to comment.
Something went wrong with that request. Please try again.