couchpillow 0.4.0 → 0.4.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.
- checksums.yaml +4 -4
- data/lib/couchpillow/document.rb +2 -3
- data/lib/couchpillow/version.rb +1 -1
- data/test/test_document.rb +18 -0
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 68340b1c8ca93e9e114eb3a9af1bd96b705e4b0a
         | 
| 4 | 
            +
              data.tar.gz: 0ba836b544c3ea80cc23f09b490cac0b0c8788ae
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 1ccd1a7058ceae8a0978fa7f2dca06282246cc756651e929d144840bb9bf177e9b2e0dbc57fbe07dcccff7cd74d1a5bfedfa70706074558d4af3c60901bbe0ea
         | 
| 7 | 
            +
              data.tar.gz: e56be83f06ef9f5e2cb9b8375772440dc59ac32040483aa7729df8a361b3a710c5e1e4617fb488f8d371d9a7da9f542943380de08ac5ad77ff06d861af0ee931
         | 
    
        data/lib/couchpillow/document.rb
    CHANGED
    
    | @@ -56,9 +56,9 @@ module CouchPillow | |
| 56 56 | 
             
                #
         | 
| 57 57 | 
             
                def save!
         | 
| 58 58 | 
             
                  whitelist!
         | 
| 59 | 
            -
                  validate!
         | 
| 60 59 | 
             
                  sort!
         | 
| 61 60 | 
             
                  timestamp!
         | 
| 61 | 
            +
                  validate!
         | 
| 62 62 | 
             
                  to_save = @data.merge({
         | 
| 63 63 | 
             
                    :_type => self.class._type
         | 
| 64 64 | 
             
                  })
         | 
| @@ -78,9 +78,9 @@ module CouchPillow | |
| 78 78 | 
             
                #
         | 
| 79 79 | 
             
                def update!
         | 
| 80 80 | 
             
                  whitelist!
         | 
| 81 | 
            -
                  validate!
         | 
| 82 81 | 
             
                  sort!
         | 
| 83 82 | 
             
                  timestamp!
         | 
| 83 | 
            +
                  validate!
         | 
| 84 84 | 
             
                  to_save = @data.merge({
         | 
| 85 85 | 
             
                    :_type => self.class._type
         | 
| 86 86 | 
             
                  })
         | 
| @@ -98,7 +98,6 @@ module CouchPillow | |
| 98 98 | 
             
                  end
         | 
| 99 99 | 
             
                  rename!
         | 
| 100 100 | 
             
                  whitelist!
         | 
| 101 | 
            -
                  validate!
         | 
| 102 101 | 
             
                end
         | 
| 103 102 |  | 
| 104 103 |  | 
    
        data/lib/couchpillow/version.rb
    CHANGED
    
    
    
        data/test/test_document.rb
    CHANGED
    
    | @@ -88,6 +88,24 @@ class TestDocument < Minitest::Test | |
| 88 88 | 
             
              end
         | 
| 89 89 |  | 
| 90 90 |  | 
| 91 | 
            +
              def test_update_doesnt_trigger_validation
         | 
| 92 | 
            +
                d = Class.new(Document) do
         | 
| 93 | 
            +
                  type 'test'
         | 
| 94 | 
            +
                  attribute(:a).type(Integer)
         | 
| 95 | 
            +
                end.new({ a: 1, b: 2})
         | 
| 96 | 
            +
                assert_equal 1, d[:a]
         | 
| 97 | 
            +
                assert_equal 1, d.a
         | 
| 98 | 
            +
                hash = {
         | 
| 99 | 
            +
                  'a' => 'too',
         | 
| 100 | 
            +
                }
         | 
| 101 | 
            +
                d.update(hash)
         | 
| 102 | 
            +
                assert_equal 'too', d.a
         | 
| 103 | 
            +
                assert_raises CouchPillow::ValidationError do
         | 
| 104 | 
            +
                  assert d.save!
         | 
| 105 | 
            +
                end
         | 
| 106 | 
            +
              end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
             | 
| 91 109 | 
             
              def test_exclusion_other_keys
         | 
| 92 110 | 
             
                d = Class.new(Document) do
         | 
| 93 111 | 
             
                  attribute :a
         |