activerecord-delay_touching 0.0.3 → 0.0.4
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/README.md +4 -2
 - data/lib/activerecord/delay_touching.rb +1 -0
 - data/lib/activerecord/delay_touching/version.rb +1 -1
 - data/spec/activerecord/delay_touching_spec.rb +22 -0
 - data/spec/support/models.rb +13 -0
 - data/spec/support/schema.rb +14 -0
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 81d58f8a4a53021f8034c2da68790d7648b2b4f3
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 2d975e4e5c14ee8baecaaf762aaa8a8ebb003bef
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 46209cc3478f9f81e932644e79364bb2ff012d536cabc2e3927cca61c74a641b0b9fc94e6522574c2c0c21281e1a0fda4df0be6db40c0f58b001d73c7ead5008
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 89654bba87280ab7976c0d464d43f4a9e0760643ce614532c12910b4e9b9602b38635815251bde5877bbd24a2c95742ca13ffac0b55bb7461a1786c0e5c077a7
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,5 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Activerecord::DelayTouching
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            > **Note:** this version supports ActiveRecord 3.2 through 4.1 only. For ActiveRecord 4.2+, please see the Master branch.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       3 
5 
     | 
    
         
             
            Batch up your ActiveRecord "touch" operations for better performance.
         
     | 
| 
       4 
6 
     | 
    
         | 
| 
       5 
7 
     | 
    
         
             
            When you want to invalidate a cache in Rails, you use `touch: true`. But when
         
     | 
| 
         @@ -13,7 +15,7 @@ round-trips as possible. Instead of N touches you get 1 touch. 
     | 
|
| 
       13 
15 
     | 
    
         | 
| 
       14 
16 
     | 
    
         
             
            Add this line to your application's Gemfile:
         
     | 
| 
       15 
17 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
                gem 'activerecord-delay_touching'
         
     | 
| 
      
 18 
     | 
    
         
            +
                gem 'activerecord-delay_touching', '~> 0.0.3'
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
       18 
20 
     | 
    
         
             
            And then execute:
         
     | 
| 
       19 
21 
     | 
    
         | 
| 
         @@ -21,7 +23,7 @@ And then execute: 
     | 
|
| 
       21 
23 
     | 
    
         | 
| 
       22 
24 
     | 
    
         
             
            Or install it yourself:
         
     | 
| 
       23 
25 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                $ gem install activerecord-delay_touching
         
     | 
| 
      
 26 
     | 
    
         
            +
                $ gem install activerecord-delay_touching -v 0.0.3
         
     | 
| 
       25 
27 
     | 
    
         | 
| 
       26 
28 
     | 
    
         
             
            ## Usage
         
     | 
| 
       27 
29 
     | 
    
         | 
| 
         @@ -151,6 +151,28 @@ describe Activerecord::DelayTouching do 
     | 
|
| 
       151 
151 
     | 
    
         
             
                end
         
     | 
| 
       152 
152 
     | 
    
         
             
              end
         
     | 
| 
       153 
153 
     | 
    
         | 
| 
      
 154 
     | 
    
         
            +
              context 'dependent deletes' do
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
                let(:post) { Post.create! }
         
     | 
| 
      
 157 
     | 
    
         
            +
                let(:user) { User.create! }
         
     | 
| 
      
 158 
     | 
    
         
            +
                let(:comment) { Comment.create! }
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
                before do
         
     | 
| 
      
 161 
     | 
    
         
            +
                  post.comments << comment
         
     | 
| 
      
 162 
     | 
    
         
            +
                  user.comments << comment
         
     | 
| 
      
 163 
     | 
    
         
            +
                end
         
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
      
 165 
     | 
    
         
            +
                it 'does not attempt to touch deleted records' do
         
     | 
| 
      
 166 
     | 
    
         
            +
                  expect do
         
     | 
| 
      
 167 
     | 
    
         
            +
                    ActiveRecord::Base.delay_touching do
         
     | 
| 
      
 168 
     | 
    
         
            +
                      post.destroy
         
     | 
| 
      
 169 
     | 
    
         
            +
                    end
         
     | 
| 
      
 170 
     | 
    
         
            +
                  end.not_to raise_error
         
     | 
| 
      
 171 
     | 
    
         
            +
                  expect(post.destroyed?).to eq true
         
     | 
| 
      
 172 
     | 
    
         
            +
                end
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
              end
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
       154 
176 
     | 
    
         
             
              def expect_updates(tables)
         
     | 
| 
       155 
177 
     | 
    
         
             
                expected_sql = tables.map do |entry|
         
     | 
| 
       156 
178 
     | 
    
         
             
                  if entry.kind_of?(Hash)
         
     | 
    
        data/spec/support/models.rb
    CHANGED
    
    | 
         @@ -5,3 +5,16 @@ end 
     | 
|
| 
       5 
5 
     | 
    
         
             
            class Pet < ActiveRecord::Base
         
     | 
| 
       6 
6 
     | 
    
         
             
              belongs_to :person, touch: true, inverse_of: :pets
         
     | 
| 
       7 
7 
     | 
    
         
             
            end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            class Post < ActiveRecord::Base
         
     | 
| 
      
 10 
     | 
    
         
            +
              has_many :comments, dependent: :destroy
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            class User < ActiveRecord::Base
         
     | 
| 
      
 14 
     | 
    
         
            +
              has_many :comments, dependent: :destroy
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            class Comment < ActiveRecord::Base
         
     | 
| 
      
 18 
     | 
    
         
            +
              belongs_to :post, touch: true
         
     | 
| 
      
 19 
     | 
    
         
            +
              belongs_to :user, touch: true
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/support/schema.rb
    CHANGED
    
    | 
         @@ -16,4 +16,18 @@ ActiveRecord::Schema.define do 
     | 
|
| 
       16 
16 
     | 
    
         
             
                t.timestamps
         
     | 
| 
       17 
17 
     | 
    
         
             
              end
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
      
 19 
     | 
    
         
            +
              create_table :posts, force: true do |t|
         
     | 
| 
      
 20 
     | 
    
         
            +
                t.timestamps null: false
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              create_table :users, force: true do |t|
         
     | 
| 
      
 24 
     | 
    
         
            +
                t.timestamps null: false
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              create_table :comments, force: true do |t|
         
     | 
| 
      
 28 
     | 
    
         
            +
                t.integer :post_id
         
     | 
| 
      
 29 
     | 
    
         
            +
                t.integer :user_id
         
     | 
| 
      
 30 
     | 
    
         
            +
                t.timestamps null: false
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
       19 
33 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: activerecord-delay_touching
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.4
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Brian Morearty
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-07-08 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activerecord
         
     | 
| 
         @@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       186 
186 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       187 
187 
     | 
    
         
             
            requirements: []
         
     | 
| 
       188 
188 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       189 
     | 
    
         
            -
            rubygems_version: 2.4. 
     | 
| 
      
 189 
     | 
    
         
            +
            rubygems_version: 2.4.8
         
     | 
| 
       190 
190 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       191 
191 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       192 
192 
     | 
    
         
             
            summary: Batch up your ActiveRecord "touch" operations for better performance.
         
     |