activerecord-delay_touching 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- 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: 731f1b62489c8675bb3df76d2d12ffb90ae5cc58
|
4
|
+
data.tar.gz: ff36c494301d616c19dd8300d05245eae989e553
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5777ddf6f855fafac79a3866fdd7940986aeb2882f5622ca31930bca8beb86d20213fef6db7957f223828e69aa17f558d4e906218d54087007f2c9408fa8307b
|
7
|
+
data.tar.gz: d0733fe1dd22034db87c60a3d46acf5a4034be3c7803c6ee3765a345735ba9c73afa563329158e8b6323837a760a434629900b4b9b50248fa5db9b9eb5509368
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Activerecord::DelayTouching
|
2
2
|
|
3
|
+
> **Note:** this version requires ActiveRecord 4.2 or higher. To use ActiveRecord 3.2 through 4.1, use the branch https://github.com/godaddy/activerecord-delay_touching/tree/pre-activerecord-4.2.
|
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
|
@@ -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: 1.0.
|
4
|
+
version: 1.0.1
|
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
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
version: '0'
|
181
181
|
requirements: []
|
182
182
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.4.
|
183
|
+
rubygems_version: 2.4.8
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: Batch up your ActiveRecord "touch" operations for better performance.
|