bartzon-validates_blacklist 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,7 +29,7 @@ Add the follow to each model you want to have validated:
29
29
 
30
30
  Adding a blacklisted value is as easy as:
31
31
 
32
- User.add_to_blacklist('value')
32
+ User.add_to_blacklist('value')
33
33
 
34
34
  Per default the scope will be inherited from the options specified in the call to validates_blacklist. This can be changed by doing:
35
35
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bartzon-validates_blacklist}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bart Zonneveld"]
@@ -42,11 +42,14 @@ module ValidatesBlacklist
42
42
  module InstanceMethods
43
43
  private
44
44
  def blacklisted_columns
45
+ result = true
45
46
  blacklist_options[:columns].each do |field|
46
47
  if self.class.blacklisted?(self.send(field))
47
48
  errors.add(field, blacklist_options[:message])
49
+ result = false
48
50
  end
49
51
  end
52
+ result
50
53
  end
51
54
  end
52
55
  end
@@ -15,6 +15,14 @@ class UserWithAllOptions < UserWithoutOptions
15
15
  :scope => 'User'
16
16
  end
17
17
 
18
+ class UserWithValidations < User
19
+ validate :other_validation
20
+
21
+ def other_validation
22
+ true
23
+ end
24
+ end
25
+
18
26
  describe "ValidatesBlacklist" do
19
27
  def create_blacklist(value, scope=nil)
20
28
  ValidatesBlacklist::Blacklist.create!(:value => value, :scope => scope)
@@ -47,6 +55,13 @@ describe "ValidatesBlacklist" do
47
55
  user = User.new
48
56
  user.errors.should be_empty
49
57
  end
58
+
59
+ it "should allow multiple validate calls" do
60
+ user = UserWithValidations.new
61
+ user.should_receive(:other_validation).once
62
+ user.should_receive(:blacklisted_columns).once
63
+ user.valid?
64
+ end
50
65
 
51
66
  describe "a model with blacklists" do
52
67
  before(:each) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bartzon-validates_blacklist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bart Zonneveld