activevalidators 1.2.2 → 1.2.3

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activevalidators (1.2.1)
4
+ activevalidators (1.2.3)
5
5
  activemodel (>= 3.0.0)
6
6
  activerecord (>= 3.0.0)
7
7
  date_validator (= 0.5.9)
@@ -4,9 +4,9 @@ $:.unshift lib unless $:.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "activevalidators"
7
- s.version = '1.2.2'
7
+ s.version = '1.2.3'
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Franck Verrot", "Paco Guzmán", "Oriol Gual"]
9
+ s.authors = ["Franck Verrot", "Paco Guzmán", "Oriol Gual", "Garrett Bjerkhoel"]
10
10
  s.email = ["franck@verrot.fr"]
11
11
  s.homepage = "http://github.com/cesario/activevalidators"
12
12
  s.summary = %q{Collection of ActiveModel/ActiveRecord validations}
@@ -2,7 +2,9 @@ module ActiveModel
2
2
  module Validations
3
3
  class SlugValidator < EachValidator
4
4
  def validate_each(record, attribute, value)
5
- unless value == value.parameterize
5
+ if value.nil?
6
+ record.errors.add_on_blank(attribute)
7
+ elsif value != value.parameterize
6
8
  record.errors.add(attribute)
7
9
  end
8
10
  end
@@ -5,7 +5,7 @@ describe "Slug Validation" do
5
5
  TestRecord.reset_callbacks(:validate)
6
6
  TestRecord.validates :slug, :slug => true
7
7
  end
8
-
8
+
9
9
  subject { TestRecord.new }
10
10
 
11
11
  it "accepts valid slugs" do
@@ -29,4 +29,16 @@ describe "Slug Validation" do
29
29
  subject.errors[:slug].should include subject.errors.generate_message(:slug, :invalid)
30
30
  end
31
31
  end
32
+
33
+ describe "for empty slugs" do
34
+ before :each do
35
+ subject.slug = nil
36
+ end
37
+
38
+ it "generates an error message of type blank" do
39
+ subject.should_not be_valid
40
+ subject.errors[:slug].should include subject.errors.generate_message(:slug, :blank)
41
+ end
42
+ end
43
+
32
44
  end
metadata CHANGED
@@ -5,18 +5,19 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 2
8
- - 2
9
- version: 1.2.2
8
+ - 3
9
+ version: 1.2.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Franck Verrot
13
13
  - "Paco Guzm\xC3\xA1n"
14
14
  - Oriol Gual
15
+ - Garrett Bjerkhoel
15
16
  autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
19
 
19
- date: 2010-12-06 00:00:00 +01:00
20
+ date: 2010-12-08 00:00:00 +01:00
20
21
  default_executable:
21
22
  dependencies:
22
23
  - !ruby/object:Gem::Dependency