Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove value conditional

  • Loading branch information...
commit 12ab764ba2f464e03a5f9168279762d9bcb3ee3b 1 parent c3b0c1f
@bcardarella bcardarella authored
View
4 lib/client_side_validations/active_model.rb
@@ -89,10 +89,8 @@ def can_use_for_client_side_validation?(attr, validator, force)
def run_conditional(method_name_value_or_proc)
if method_name_value_or_proc.respond_to?(:call)
method_name_value_or_proc.call(self)
- elsif (method_name_value_or_proc.is_a?(Symbol) || method_name_value_or_proc.is_a?(String)) && respond_to?(method_name_value_or_proc)
- self.send(method_name_value_or_proc)
else
- method_name_value_or_proc
+ self.send(method_name_value_or_proc)
end
end
View
31 test/active_model/cases/test_validations.rb
@@ -359,37 +359,6 @@ def cannot_validate?
assert_equal expected_hash, person.client_side_validation_hash(true)
end
- def test_conditional_with_values
- person = new_person do |p|
- p.validates :first_name, :presence => { :if => true }
- p.validates :last_name, :presence => { :unless => false }
-
- p.class_eval do
- def can_validate?
- true
- end
-
- def cannot_validate?
- false
- end
- end
- end
-
- expected_hash = {
- :first_name => {
- :presence => [{
- :message => "can't be blank"
- }]
- },
- :last_name => {
- :presence => [{
- :message => "can't be blank"
- }]
- }
- }
- assert_equal expected_hash, person.client_side_validation_hash(true)
- end
-
def test_conditionals_forced_when_used_changed_helpers
person = new_person do |p|
p.validates :first_name, :presence => { :if => :first_name_changed? }
Please sign in to comment.
Something went wrong with that request. Please try again.