grouped_validations 0.3.2 → 0.3.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 +2 -2
 - data/lib/grouped_validations/active_model.rb +5 -3
 - data/lib/grouped_validations/version.rb +1 -1
 - data/spec/grouped_validations_spec.rb +18 -0
 - metadata +26 -42
 - data/Gemfile.lock +0 -41
 
    
        data/Gemfile
    CHANGED
    
    
| 
         @@ -10,14 +10,16 @@ module ActiveModel 
     | 
|
| 
       10 
10 
     | 
    
         
             
                      include GroupedValidations
         
     | 
| 
       11 
11 
     | 
    
         
             
                    end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                     
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
                    unless validation_groups.include?(group)
         
     | 
| 
      
 14 
     | 
    
         
            +
                      validation_groups << group
         
     | 
| 
      
 15 
     | 
    
         
            +
                      _define_group_validation_callbacks(group)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    end
         
     | 
| 
       16 
17 
     | 
    
         | 
| 
       17 
18 
     | 
    
         
             
                    options[:name] = group
         
     | 
| 
       18 
19 
     | 
    
         | 
| 
       19 
20 
     | 
    
         
             
                    if block.arity == 1
         
     | 
| 
       20 
21 
     | 
    
         
             
                      @_current_validation_group = options.merge(:with_options => true)
         
     | 
| 
      
 22 
     | 
    
         
            +
                      
         
     | 
| 
       21 
23 
     | 
    
         
             
                      with_options(options.except(:name)) do |config|
         
     | 
| 
       22 
24 
     | 
    
         
             
                        yield config
         
     | 
| 
       23 
25 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -27,6 +27,24 @@ describe GroupedValidations do 
     | 
|
| 
       27 
27 
     | 
    
         
             
                  person.group_valid?(:dummy)
         
     | 
| 
       28 
28 
     | 
    
         
             
                end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
      
 30 
     | 
    
         
            +
                it "it should not overwrite group when defined again" do
         
     | 
| 
      
 31 
     | 
    
         
            +
                  Person.class_eval do
         
     | 
| 
      
 32 
     | 
    
         
            +
                    validation_group(:name) { 
         
     | 
| 
      
 33 
     | 
    
         
            +
                      validates_presence_of :first_name
         
     | 
| 
      
 34 
     | 
    
         
            +
                    }
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    validation_group(:name) { 
         
     | 
| 
      
 37 
     | 
    
         
            +
                      validates_presence_of :last_name
         
     | 
| 
      
 38 
     | 
    
         
            +
                    }
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
                  
         
     | 
| 
      
 41 
     | 
    
         
            +
                  person.group_valid?(:name)
         
     | 
| 
      
 42 
     | 
    
         
            +
                  
         
     | 
| 
      
 43 
     | 
    
         
            +
                  person.should have(2).errors
         
     | 
| 
      
 44 
     | 
    
         
            +
                  person.errors[:first_name].should_not be_empty
         
     | 
| 
      
 45 
     | 
    
         
            +
                  person.errors[:last_name].should_not be_empty
         
     | 
| 
      
 46 
     | 
    
         
            +
                end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
       30 
48 
     | 
    
         
             
                context "with options" do
         
     | 
| 
       31 
49 
     | 
    
         
             
                  context "as implicit block" do
         
     | 
| 
       32 
50 
     | 
    
         
             
                    it 'should pass options for group to validations' do
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,35 +1,25 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            --- !ruby/object:Gem::Specification 
     | 
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: grouped_validations
         
     | 
| 
       3 
     | 
    
         
            -
            version: !ruby/object:Gem::Version 
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.3
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
     | 
    
         
            -
              segments: 
         
     | 
| 
       7 
     | 
    
         
            -
              - 0
         
     | 
| 
       8 
     | 
    
         
            -
              - 3
         
     | 
| 
       9 
     | 
    
         
            -
              - 2
         
     | 
| 
       10 
     | 
    
         
            -
              version: 0.3.2
         
     | 
| 
       11 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
     | 
    
         
            -
            authors: 
     | 
| 
      
 7 
     | 
    
         
            +
            authors:
         
     | 
| 
       13 
8 
     | 
    
         
             
            - Adam Meehan
         
     | 
| 
       14 
9 
     | 
    
         
             
            autorequire: grouped_validations
         
     | 
| 
       15 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
            date: 2012-08-18 00:00:00 +10:00
         
     | 
| 
       19 
     | 
    
         
            -
            default_executable: 
         
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2013-09-29 00:00:00.000000000 Z
         
     | 
| 
       20 
13 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
            description: Define validation groups in a model for greater control over which validations
         
     | 
| 
      
 15 
     | 
    
         
            +
              are run.
         
     | 
| 
       23 
16 
     | 
    
         
             
            email: adam.meehan@gmail.com
         
     | 
| 
       24 
17 
     | 
    
         
             
            executables: []
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
18 
     | 
    
         
             
            extensions: []
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
            extra_rdoc_files: 
         
     | 
| 
      
 19 
     | 
    
         
            +
            extra_rdoc_files:
         
     | 
| 
       29 
20 
     | 
    
         
             
            - README.rdoc
         
     | 
| 
       30 
     | 
    
         
            -
            files: 
     | 
| 
      
 21 
     | 
    
         
            +
            files:
         
     | 
| 
       31 
22 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       32 
     | 
    
         
            -
            - Gemfile.lock
         
     | 
| 
       33 
23 
     | 
    
         
             
            - MIT-LICENSE
         
     | 
| 
       34 
24 
     | 
    
         
             
            - README.rdoc
         
     | 
| 
       35 
25 
     | 
    
         
             
            - Rakefile
         
     | 
| 
         @@ -40,40 +30,34 @@ files: 
     | 
|
| 
       40 
30 
     | 
    
         
             
            - lib/grouped_validations/version.rb
         
     | 
| 
       41 
31 
     | 
    
         
             
            - spec/grouped_validations_spec.rb
         
     | 
| 
       42 
32 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       43 
     | 
    
         
            -
            has_rdoc: true
         
     | 
| 
       44 
33 
     | 
    
         
             
            homepage: http://github.com/adzap/grouped_validations
         
     | 
| 
       45 
34 
     | 
    
         
             
            licenses: []
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
35 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       48 
36 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
            require_paths: 
         
     | 
| 
      
 37 
     | 
    
         
            +
            require_paths:
         
     | 
| 
       51 
38 
     | 
    
         
             
            - lib
         
     | 
| 
       52 
     | 
    
         
            -
            required_ruby_version: !ruby/object:Gem::Requirement 
     | 
| 
      
 39 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
       53 
40 
     | 
    
         
             
              none: false
         
     | 
| 
       54 
     | 
    
         
            -
              requirements: 
     | 
| 
       55 
     | 
    
         
            -
              - -  
     | 
| 
       56 
     | 
    
         
            -
                - !ruby/object:Gem::Version 
     | 
| 
       57 
     | 
    
         
            -
                   
     | 
| 
       58 
     | 
    
         
            -
                  segments: 
     | 
| 
      
 41 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 42 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 43 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 44 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 45 
     | 
    
         
            +
                  segments:
         
     | 
| 
       59 
46 
     | 
    
         
             
                  - 0
         
     | 
| 
       60 
     | 
    
         
            -
                   
     | 
| 
       61 
     | 
    
         
            -
            required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
| 
      
 47 
     | 
    
         
            +
                  hash: 2818455571413167063
         
     | 
| 
      
 48 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       62 
49 
     | 
    
         
             
              none: false
         
     | 
| 
       63 
     | 
    
         
            -
              requirements: 
     | 
| 
       64 
     | 
    
         
            -
              - -  
     | 
| 
       65 
     | 
    
         
            -
                - !ruby/object:Gem::Version 
     | 
| 
       66 
     | 
    
         
            -
                   
     | 
| 
       67 
     | 
    
         
            -
                  segments: 
         
     | 
| 
       68 
     | 
    
         
            -
                  - 0
         
     | 
| 
       69 
     | 
    
         
            -
                  version: "0"
         
     | 
| 
      
 50 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 51 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 52 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 53 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
       70 
54 
     | 
    
         
             
            requirements: []
         
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
55 
     | 
    
         
             
            rubyforge_project: grouped_validations
         
     | 
| 
       73 
     | 
    
         
            -
            rubygems_version: 1. 
     | 
| 
      
 56 
     | 
    
         
            +
            rubygems_version: 1.8.23
         
     | 
| 
       74 
57 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       75 
58 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       76 
     | 
    
         
            -
            summary: Define validation groups in a model for greater control over which validations 
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
      
 59 
     | 
    
         
            +
            summary: Define validation groups in a model for greater control over which validations
         
     | 
| 
      
 60 
     | 
    
         
            +
              are run.
         
     | 
| 
      
 61 
     | 
    
         
            +
            test_files:
         
     | 
| 
       78 
62 
     | 
    
         
             
            - spec/grouped_validations_spec.rb
         
     | 
| 
       79 
63 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
    
        data/Gemfile.lock
    DELETED
    
    | 
         @@ -1,41 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            GEM
         
     | 
| 
       2 
     | 
    
         
            -
              remote: http://rubygems.org/
         
     | 
| 
       3 
     | 
    
         
            -
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                activemodel (3.2.2)
         
     | 
| 
       5 
     | 
    
         
            -
                  activesupport (= 3.2.2)
         
     | 
| 
       6 
     | 
    
         
            -
                  builder (~> 3.0.0)
         
     | 
| 
       7 
     | 
    
         
            -
                activesupport (3.2.2)
         
     | 
| 
       8 
     | 
    
         
            -
                  i18n (~> 0.6)
         
     | 
| 
       9 
     | 
    
         
            -
                  multi_json (~> 1.0)
         
     | 
| 
       10 
     | 
    
         
            -
                builder (3.0.0)
         
     | 
| 
       11 
     | 
    
         
            -
                columnize (0.3.1)
         
     | 
| 
       12 
     | 
    
         
            -
                diff-lcs (1.1.2)
         
     | 
| 
       13 
     | 
    
         
            -
                i18n (0.6.0)
         
     | 
| 
       14 
     | 
    
         
            -
                linecache (0.43)
         
     | 
| 
       15 
     | 
    
         
            -
                multi_json (1.1.0)
         
     | 
| 
       16 
     | 
    
         
            -
                rake (0.8.7)
         
     | 
| 
       17 
     | 
    
         
            -
                rspec (2.0.1)
         
     | 
| 
       18 
     | 
    
         
            -
                  rspec-core (~> 2.0.1)
         
     | 
| 
       19 
     | 
    
         
            -
                  rspec-expectations (~> 2.0.1)
         
     | 
| 
       20 
     | 
    
         
            -
                  rspec-mocks (~> 2.0.1)
         
     | 
| 
       21 
     | 
    
         
            -
                rspec-core (2.0.1)
         
     | 
| 
       22 
     | 
    
         
            -
                rspec-expectations (2.0.1)
         
     | 
| 
       23 
     | 
    
         
            -
                  diff-lcs (>= 1.1.2)
         
     | 
| 
       24 
     | 
    
         
            -
                rspec-mocks (2.0.1)
         
     | 
| 
       25 
     | 
    
         
            -
                  rspec-core (~> 2.0.1)
         
     | 
| 
       26 
     | 
    
         
            -
                  rspec-expectations (~> 2.0.1)
         
     | 
| 
       27 
     | 
    
         
            -
                ruby-debug (0.10.3)
         
     | 
| 
       28 
     | 
    
         
            -
                  columnize (>= 0.1)
         
     | 
| 
       29 
     | 
    
         
            -
                  ruby-debug-base (~> 0.10.3.0)
         
     | 
| 
       30 
     | 
    
         
            -
                ruby-debug-base (0.10.3)
         
     | 
| 
       31 
     | 
    
         
            -
                  linecache (>= 0.3)
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
            PLATFORMS
         
     | 
| 
       34 
     | 
    
         
            -
              ruby
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
            DEPENDENCIES
         
     | 
| 
       37 
     | 
    
         
            -
              activemodel (~> 3.2.0)
         
     | 
| 
       38 
     | 
    
         
            -
              activesupport (~> 3.2.0)
         
     | 
| 
       39 
     | 
    
         
            -
              rake (~> 0.8.7)
         
     | 
| 
       40 
     | 
    
         
            -
              rspec (~> 2.0.0)
         
     | 
| 
       41 
     | 
    
         
            -
              ruby-debug
         
     |