second_level_cache 2.2.2 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/lib/second_level_cache/active_record/persistence.rb +3 -2
- data/lib/second_level_cache/record_marshal.rb +4 -0
- data/lib/second_level_cache/version.rb +1 -1
- data/second_level_cache.gemspec +2 -2
- data/test/enum_attr_test.rb +13 -0
- data/test/model/user.rb +3 -0
- data/test/persistence_test.rb +24 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ce12cd0acb8898804a3fc70bbb9233292c6bd22
|
4
|
+
data.tar.gz: 99cd8136503846c6c6f990993ac92f962ec52131
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd5fbfcd0a891a32d1533de644842466666af3bcccd050c149d383bd369503779c8a19f982f4cdf2e10926ad32ffe2345fb86a581d8dcc4f6e51ae800d2150cf
|
7
|
+
data.tar.gz: f513fd3a81f95a8ddd029fc7265de7bd76737f6feaf5745c50f793a96f2f8519562cb3c42888b41d75dca6ed16883ede4f058271a382c812236a94034cc327c2
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
module SecondLevelCache
|
2
2
|
module ActiveRecord
|
3
3
|
module Persistence
|
4
|
-
|
5
|
-
|
4
|
+
# update_column will call update_columns
|
5
|
+
def update_columns(attributes)
|
6
|
+
super(attributes).tap { update_second_level_cache }
|
6
7
|
end
|
7
8
|
|
8
9
|
def reload(options = nil)
|
data/second_level_cache.gemspec
CHANGED
@@ -30,8 +30,8 @@ Gem::Specification.new do |gem|
|
|
30
30
|
gem.require_paths = ['lib']
|
31
31
|
gem.version = SecondLevelCache::VERSION
|
32
32
|
|
33
|
-
gem.add_runtime_dependency 'activesupport', ['>= 5.0.0.
|
34
|
-
gem.add_runtime_dependency 'activerecord', ['>= 5.0.0.
|
33
|
+
gem.add_runtime_dependency 'activesupport', ['>= 5.0.0.beta3', '< 5.1.0']
|
34
|
+
gem.add_runtime_dependency 'activerecord', ['>= 5.0.0.beta3', '< 5.1.0']
|
35
35
|
|
36
36
|
gem.add_development_dependency 'sqlite3'
|
37
37
|
gem.add_development_dependency 'rake'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class EnumAttrTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
@user = User.create name: 'csdn', email: 'test@csdn.com'
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_enum_attr
|
9
|
+
@user.archived!
|
10
|
+
assert_equal 'archived', @user.status
|
11
|
+
assert_equal 'archived', User.find(@user.id).status
|
12
|
+
end
|
13
|
+
end
|
data/test/model/user.rb
CHANGED
@@ -3,6 +3,7 @@ ActiveRecord::Base.connection.create_table(:users, force: true) do |t|
|
|
3
3
|
t.text :json_options
|
4
4
|
t.string :name, unique: true
|
5
5
|
t.string :email
|
6
|
+
t.integer :status, default: 0
|
6
7
|
t.integer :books_count, default: 0
|
7
8
|
t.integer :images_count, default: 0
|
8
9
|
t.timestamps null: false
|
@@ -33,6 +34,8 @@ class User < ActiveRecord::Base
|
|
33
34
|
has_one :namespace, -> { where(kind: nil) }
|
34
35
|
has_many :books
|
35
36
|
has_many :images, as: :imagable
|
37
|
+
|
38
|
+
enum status: [:active, :archived]
|
36
39
|
end
|
37
40
|
|
38
41
|
class Namespace < ActiveRecord::Base
|
data/test/persistence_test.rb
CHANGED
@@ -31,6 +31,30 @@ class PersistenceTest < ActiveSupport::TestCase
|
|
31
31
|
assert_equal new_user, @user
|
32
32
|
end
|
33
33
|
|
34
|
+
def test_should_update_cache_after_update_columns
|
35
|
+
@user.update_columns name: 'new_name1'
|
36
|
+
new_user = User.find @user.id
|
37
|
+
assert_equal new_user, @user
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_should_update_cache_after_update_attribute
|
41
|
+
@user.update_attribute :name, 'new_name'
|
42
|
+
new_user = User.find @user.id
|
43
|
+
assert_equal new_user, @user
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_should_update_cache_after_update
|
47
|
+
@user.update name: 'new_name'
|
48
|
+
new_user = User.find @user.id
|
49
|
+
assert_equal new_user, @user
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_should_update_cache_after_update!
|
53
|
+
@user.update! name: 'new_name'
|
54
|
+
new_user = User.find @user.id
|
55
|
+
assert_equal new_user, @user
|
56
|
+
end
|
57
|
+
|
34
58
|
def test_should_return_true_if_touch_ok
|
35
59
|
assert @topic.touch == true
|
36
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: second_level_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hooopo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.0.0.
|
19
|
+
version: 5.0.0.beta3
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 5.1.0
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 5.0.0.
|
29
|
+
version: 5.0.0.beta3
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 5.1.0
|
@@ -36,7 +36,7 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 5.0.0.
|
39
|
+
version: 5.0.0.beta3
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 5.1.0
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 5.0.0.
|
49
|
+
version: 5.0.0.beta3
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 5.1.0
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- test/active_record_test_case_helper.rb
|
151
151
|
- test/base_test.rb
|
152
152
|
- test/belongs_to_association_test.rb
|
153
|
+
- test/enum_attr_test.rb
|
153
154
|
- test/fetch_by_uniq_key_test.rb
|
154
155
|
- test/finder_methods_test.rb
|
155
156
|
- test/has_one_association_test.rb
|
@@ -200,6 +201,7 @@ test_files:
|
|
200
201
|
- test/active_record_test_case_helper.rb
|
201
202
|
- test/base_test.rb
|
202
203
|
- test/belongs_to_association_test.rb
|
204
|
+
- test/enum_attr_test.rb
|
203
205
|
- test/fetch_by_uniq_key_test.rb
|
204
206
|
- test/finder_methods_test.rb
|
205
207
|
- test/has_one_association_test.rb
|