whyvalidationssuckin96 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.1
|
@@ -43,9 +43,12 @@ module WhyValidationsSuckIn96
|
|
43
43
|
# Performs the validation, returning true or false if the validation passes or fails,
|
44
44
|
# or nil if the validation will not run.
|
45
45
|
# @return [true, false, nil]
|
46
|
+
#
|
47
|
+
# @todo - this method is uuuuuuuugly
|
46
48
|
def validates?
|
47
49
|
if options[:array]
|
48
50
|
return @passed = nil if skip_on_empty?
|
51
|
+
return @passed = false if !skip_on_empty? && Array(validatable.send(options[:attribute])).empty?
|
49
52
|
reset
|
50
53
|
@pos = 0
|
51
54
|
statuses = []
|
@@ -86,6 +86,11 @@ context "attribute based validation mixin" do
|
|
86
86
|
first_failed && inst.validates?
|
87
87
|
end
|
88
88
|
|
89
|
+
should "fail if allow_empty is false and the collection is empty" do
|
90
|
+
inst = topic.new(OpenStruct.new(:test => []), :attribute => :test, :array => true, :allow_empty => false)
|
91
|
+
inst.validates?
|
92
|
+
end.equals(false)
|
93
|
+
|
89
94
|
context "with :allow_empty" do
|
90
95
|
should "skip validation if the array is empty" do
|
91
96
|
inst = topic.new(OpenStruct.new(:test => []), :allow_empty => true, :attribute => :test, :array => true)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{whyvalidationssuckin96}
|
8
|
-
s.version = "1.6.
|
8
|
+
s.version = "1.6.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["gabrielg", "douglasmeyer"]
|