jnunemaker-validatable 1.8.1 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
 
4
+ require File.dirname(__FILE__) + '/lib/validatable'
5
+
4
6
  require 'jeweler'
5
7
  Jeweler::Tasks.new do |gem|
6
8
  gem.name = "jnunemaker-validatable"
@@ -10,6 +12,7 @@ Jeweler::Tasks.new do |gem|
10
12
  gem.homepage = "http://github.com/jnunemaker/validatable"
11
13
  gem.authors = ['Jay Fields', 'John Nunemaker']
12
14
  gem.files = FileList['lib/**/*.rb', '[A-Z]*', 'test/**/*'].to_a
15
+ gem.version = Validatable::Version
13
16
  end
14
17
 
15
18
  Jeweler::GemcutterTasks.new
@@ -1,5 +1,5 @@
1
1
  require 'forwardable'
2
- require 'active_support'
2
+ require 'active_support/all'
3
3
 
4
4
  require 'validatable/object_extension'
5
5
  require 'validatable/errors'
@@ -22,3 +22,7 @@ require 'validatable/validations/validates_exclusion_of'
22
22
  require 'validatable/validations/validates_inclusion_of'
23
23
  require 'validatable/validations/validates_each'
24
24
  require 'validatable/validations/validates_associated'
25
+
26
+ module Validatable
27
+ Version = '1.8.2'
28
+ end
@@ -2,10 +2,6 @@ module Validatable
2
2
  def self.included(klass) #:nodoc:
3
3
  klass.extend Validatable::ClassMethods
4
4
  klass.extend Validatable::Macros
5
- klass.class_eval do
6
- include ActiveSupport::Callbacks
7
- define_callbacks :validate, :validate_on_create, :validate_on_update
8
- end
9
5
  end
10
6
 
11
7
  # call-seq: valid?
@@ -23,14 +19,8 @@ module Validatable
23
19
  end
24
20
 
25
21
  def valid_for_group?(group) #:nodoc:
26
- run_before_validations
27
22
  errors.clear
28
- run_callbacks(:validate)
29
-
30
- if respond_to?(:new?)
31
- new? ? run_callbacks(:validate_on_create) : run_callbacks(:validate_on_update)
32
- end
33
-
23
+ run_before_validations
34
24
  self.class.validate_children(self, group)
35
25
  self.validate_group(group)
36
26
  errors.empty?
@@ -516,120 +516,4 @@ functional_tests do
516
516
  instance.validate_only("presence_of/name")
517
517
  instance.errors.on(:address)
518
518
  end
519
-
520
- test 'validate callback' do
521
- klass = Class.new do
522
- include Validatable
523
- attr_accessor :action
524
- validate :action_presence
525
-
526
- private
527
- def action_presence
528
- errors.add(:action, 'is invalid') if action.blank?
529
- end
530
- end
531
- instance = klass.new
532
- instance.valid?
533
- assert_equal 'is invalid', instance.errors.on(:action)
534
-
535
- instance.action = 'walk'
536
- instance.valid?
537
- assert_nil instance.errors.on(:action)
538
- end
539
-
540
- test 'validate on create callback for new record' do
541
- klass = Class.new do
542
- include Validatable
543
- attr_accessor :action
544
- validate_on_create :action_presence
545
-
546
- def new?
547
- true
548
- end
549
-
550
- private
551
- def action_presence
552
- errors.add(:action, 'is invalid') if action.blank?
553
- end
554
- end
555
- instance = klass.new
556
- instance.valid?
557
- assert_equal 'is invalid', instance.errors.on(:action)
558
-
559
- instance.action = 'walk'
560
- instance.valid?
561
- assert_nil instance.errors.on(:action)
562
- end
563
-
564
- test 'validate on create callback for not new record' do
565
- klass = Class.new do
566
- include Validatable
567
- attr_accessor :action
568
- validate_on_create :action_presence
569
-
570
- def new?
571
- false
572
- end
573
-
574
- private
575
- def action_presence
576
- errors.add(:action, 'is invalid') if action.blank?
577
- end
578
- end
579
- instance = klass.new
580
- instance.valid?
581
- assert_nil instance.errors.on(:action)
582
-
583
- instance.action = 'walk'
584
- instance.valid?
585
- assert_nil instance.errors.on(:action)
586
- end
587
-
588
- test 'validate on update callback for new record' do
589
- klass = Class.new do
590
- include Validatable
591
- attr_accessor :action
592
- validate_on_update :action_presence
593
-
594
- def new?
595
- true
596
- end
597
-
598
- private
599
- def action_presence
600
- errors.add(:action, 'is invalid') if action.blank?
601
- end
602
- end
603
- instance = klass.new
604
- instance.valid?
605
- assert_nil instance.errors.on(:action)
606
-
607
- instance.action = 'walk'
608
- instance.valid?
609
- assert_nil instance.errors.on(:action)
610
- end
611
-
612
- test 'validate on update callback for not new record' do
613
- klass = Class.new do
614
- include Validatable
615
- attr_accessor :action
616
- validate_on_update :action_presence
617
-
618
- def new?
619
- false
620
- end
621
-
622
- private
623
- def action_presence
624
- errors.add(:action, 'is invalid') if action.blank?
625
- end
626
- end
627
- instance = klass.new
628
- instance.valid?
629
- assert_equal 'is invalid', instance.errors.on(:action)
630
-
631
- instance.action = 'walk'
632
- instance.valid?
633
- assert_nil instance.errors.on(:action)
634
- end
635
519
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jnunemaker-validatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Fields
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-11-01 00:00:00 -04:00
13
+ date: 2010-02-28 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies: []
16
16