Skip to content

Commit

Permalink
Acceptance validation + test
Browse files Browse the repository at this point in the history
  • Loading branch information
porras committed Oct 3, 2007
1 parent 3a404ef commit 57adc85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/live_validations.rb
Expand Up @@ -11,7 +11,8 @@ module Validations
:presence => "Validate.Presence",
:numericality => "Validate.Numericality",
:format => "Validate.Format",
:length => "Validate.Length"
:length => "Validate.Length",
:acceptance => "Validate.Acceptance"
}


Expand Down Expand Up @@ -64,4 +65,4 @@ def map_configuration(configuration, type = nil)
end
end
end
end
end
8 changes: 8 additions & 0 deletions test/live_validations_test.rb
Expand Up @@ -16,6 +16,7 @@ class Resource < ActiveRecord::Base
column :id, :integer
column :name, :string
column :amount, :integer
column :conditions, :boolean
end

class LiveValidationTest < Test::Unit::TestCase
Expand Down Expand Up @@ -113,4 +114,11 @@ def test_length_exact
assert_equal(5, Resource.live_validations[:name][:length][:is])
end

def test_acceptance
Resource.class_eval do
validates_acceptance_of :conditions, :message => "you must accept conditions"
end
assert_equal("you must accept conditions", Resource.live_validations[:conditions][:acceptance][:failureMessage])
end

end

0 comments on commit 57adc85

Please sign in to comment.