diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-17 12:01:30 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-17 12:01:30 -0700 |
commit | f796ed6088ab1e347fcfe573a6346d1235453156 (patch) | |
tree | 81c7e25d21ac4dd5f26bd3c6ca91f8d0be7c2cbf /activemodel/test/cases/validations/numericality_validation_test.rb | |
parent | eaf54865b1313094ffca16aca1b199394bc58bae (diff) | |
parent | 677b64fcd527529390e232ceedf8fa8bfac224e2 (diff) | |
download | rails-f796ed6088ab1e347fcfe573a6346d1235453156.tar.gz rails-f796ed6088ab1e347fcfe573a6346d1235453156.tar.bz2 rails-f796ed6088ab1e347fcfe573a6346d1235453156.zip |
Merge branch 'master' into stmt
* master: (330 commits)
plugin new missing license spec
let Ruby do the is_a check for us
Mocha 0.14.0 was released with MT5 support. Switch back to gem
Fix named routing regression from 3.2.13
Revert "just call the class method since we know the callbacks are stored at the"
test refactor
Add more data to AR::UnknownAttributeError
Raise when multiple included blocks are defined
Revert "Integration tests support the OPTIONS http method"
restore whitespace in Gemfile between sqlite3 and sprockets
Revert "Add the options method to action_controller testcase."
Check if APP_RAKEFILE is defined
Fix detection of engine in rake db:load_config Broken by d1d7c86d0c8dcb7e75a87644b330c4e9e7d6c1c1
Remove trailing line break
tiny types should only be integers when the length is <= 1. fixes #10620
add failing test exposing mysql adapter tinyint bug
require things we need
Revert "Merge pull request #10600 from aditya-kapoor/code_refactor"
just call the class method since we know the callbacks are stored at the class level
this variable is used, so we don't have to use double assignments
...
Diffstat (limited to 'activemodel/test/cases/validations/numericality_validation_test.rb')
-rw-r--r-- | activemodel/test/cases/validations/numericality_validation_test.rb | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/activemodel/test/cases/validations/numericality_validation_test.rb b/activemodel/test/cases/validations/numericality_validation_test.rb index 6742a4bab0..84332ed014 100644 --- a/activemodel/test/cases/validations/numericality_validation_test.rb +++ b/activemodel/test/cases/validations/numericality_validation_test.rb @@ -30,84 +30,84 @@ class NumericalityValidationTest < ActiveModel::TestCase end def test_validates_numericality_of_with_nil_allowed - Topic.validates_numericality_of :approved, :allow_nil => true + Topic.validates_numericality_of :approved, allow_nil: true invalid!(JUNK + BLANK) valid!(NIL + FLOATS + INTEGERS + BIGDECIMAL + INFINITY) end def test_validates_numericality_of_with_integer_only - Topic.validates_numericality_of :approved, :only_integer => true + Topic.validates_numericality_of :approved, only_integer: true invalid!(NIL + BLANK + JUNK + FLOATS + BIGDECIMAL + INFINITY) valid!(INTEGERS) end def test_validates_numericality_of_with_integer_only_and_nil_allowed - Topic.validates_numericality_of :approved, :only_integer => true, :allow_nil => true + Topic.validates_numericality_of :approved, only_integer: true, allow_nil: true invalid!(JUNK + BLANK + FLOATS + BIGDECIMAL + INFINITY) valid!(NIL + INTEGERS) end def test_validates_numericality_with_greater_than - Topic.validates_numericality_of :approved, :greater_than => 10 + Topic.validates_numericality_of :approved, greater_than: 10 invalid!([-10, 10], 'must be greater than 10') valid!([11]) end def test_validates_numericality_with_greater_than_or_equal - Topic.validates_numericality_of :approved, :greater_than_or_equal_to => 10 + Topic.validates_numericality_of :approved, greater_than_or_equal_to: 10 invalid!([-9, 9], 'must be greater than or equal to 10') valid!([10]) end def test_validates_numericality_with_equal_to - Topic.validates_numericality_of :approved, :equal_to => 10 + Topic.validates_numericality_of :approved, equal_to: 10 invalid!([-10, 11] + INFINITY, 'must be equal to 10') valid!([10]) end def test_validates_numericality_with_less_than - Topic.validates_numericality_of :approved, :less_than => 10 + Topic.validates_numericality_of :approved, less_than: 10 invalid!([10], 'must be less than 10') valid!([-9, 9]) end def test_validates_numericality_with_less_than_or_equal_to - Topic.validates_numericality_of :approved, :less_than_or_equal_to => 10 + Topic.validates_numericality_of :approved, less_than_or_equal_to: 10 invalid!([11], 'must be less than or equal to 10') valid!([-10, 10]) end def test_validates_numericality_with_odd - Topic.validates_numericality_of :approved, :odd => true + Topic.validates_numericality_of :approved, odd: true invalid!([-2, 2], 'must be odd') valid!([-1, 1]) end def test_validates_numericality_with_even - Topic.validates_numericality_of :approved, :even => true + Topic.validates_numericality_of :approved, even: true invalid!([-1, 1], 'must be even') valid!([-2, 2]) end def test_validates_numericality_with_greater_than_less_than_and_even - Topic.validates_numericality_of :approved, :greater_than => 1, :less_than => 4, :even => true + Topic.validates_numericality_of :approved, greater_than: 1, less_than: 4, even: true invalid!([1, 3, 4]) valid!([2]) end def test_validates_numericality_with_other_than - Topic.validates_numericality_of :approved, :other_than => 0 + Topic.validates_numericality_of :approved, other_than: 0 invalid!([0, 0.0]) valid!([-1, 42]) @@ -115,7 +115,7 @@ class NumericalityValidationTest < ActiveModel::TestCase def test_validates_numericality_with_proc Topic.send(:define_method, :min_approved, lambda { 5 }) - Topic.validates_numericality_of :approved, :greater_than_or_equal_to => Proc.new {|topic| topic.min_approved } + Topic.validates_numericality_of :approved, greater_than_or_equal_to: Proc.new {|topic| topic.min_approved } invalid!([3, 4]) valid!([5, 6]) @@ -124,7 +124,7 @@ class NumericalityValidationTest < ActiveModel::TestCase def test_validates_numericality_with_symbol Topic.send(:define_method, :max_approved, lambda { 5 }) - Topic.validates_numericality_of :approved, :less_than_or_equal_to => :max_approved + Topic.validates_numericality_of :approved, less_than_or_equal_to: :max_approved invalid!([6]) valid!([4, 5]) @@ -132,13 +132,13 @@ class NumericalityValidationTest < ActiveModel::TestCase end def test_validates_numericality_with_numeric_message - Topic.validates_numericality_of :approved, :less_than => 4, :message => "smaller than %{count}" + Topic.validates_numericality_of :approved, less_than: 4, message: "smaller than %{count}" topic = Topic.new("title" => "numeric test", "approved" => 10) assert !topic.valid? assert_equal ["smaller than 4"], topic.errors[:approved] - Topic.validates_numericality_of :approved, :greater_than => 4, :message => "greater than %{count}" + Topic.validates_numericality_of :approved, greater_than: 4, message: "greater than %{count}" topic = Topic.new("title" => "numeric test", "approved" => 1) assert !topic.valid? @@ -146,7 +146,7 @@ class NumericalityValidationTest < ActiveModel::TestCase end def test_validates_numericality_of_for_ruby_class - Person.validates_numericality_of :karma, :allow_nil => false + Person.validates_numericality_of :karma, allow_nil: false p = Person.new p.karma = "Pix" @@ -161,11 +161,11 @@ class NumericalityValidationTest < ActiveModel::TestCase end def test_validates_numericality_with_invalid_args - assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :greater_than_or_equal_to => "foo" } - assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :less_than_or_equal_to => "foo" } - assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :greater_than => "foo" } - assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :less_than => "foo" } - assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :equal_to => "foo" } + assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, greater_than_or_equal_to: "foo" } + assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, less_than_or_equal_to: "foo" } + assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, greater_than: "foo" } + assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, less_than: "foo" } + assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, equal_to: "foo" } end private @@ -185,7 +185,7 @@ class NumericalityValidationTest < ActiveModel::TestCase end def with_each_topic_approved_value(values) - topic = Topic.new(:title => "numeric test", :content => "whatever") + topic = Topic.new(title: "numeric test", content: "whatever") values.each do |value| topic.approved = value yield topic, value |