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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88a2a566c9af218fbcb4ba47cde3b0dddfcedc2b
4
- data.tar.gz: 36e45a2c4efa464094022cab997b0ece390d164b
3
+ metadata.gz: 7ce12cd0acb8898804a3fc70bbb9233292c6bd22
4
+ data.tar.gz: 99cd8136503846c6c6f990993ac92f962ec52131
5
5
  SHA512:
6
- metadata.gz: 2e501d209a3b2f6d9790fc813a558cea3a944457fdbda0b0d657835e30193a4592585e0a22b8f9e957298cf381e3bc902832ee11eecc69e323432d26ff934597
7
- data.tar.gz: 0051c2f3c1e1110dc7088ffb2b1451e095a7872291e8efc04e42ecf68bb6fdcbfe7545e0e3d71379902495d488b5f562871dde3c3f0a148600a24db25329ddf2
6
+ metadata.gz: bd5fbfcd0a891a32d1533de644842466666af3bcccd050c149d383bd369503779c8a19f982f4cdf2e10926ad32ffe2345fb86a581d8dcc4f6e51ae800d2150cf
7
+ data.tar.gz: f513fd3a81f95a8ddd029fc7265de7bd76737f6feaf5745c50f793a96f2f8519562cb3c42888b41d75dca6ed16883ede4f058271a382c812236a94034cc327c2
data/Gemfile CHANGED
@@ -2,4 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 5.0.0.beta2'
5
+ gem 'rails', '~> 5.0.0'
data/README.md CHANGED
@@ -19,7 +19,7 @@ In your gem file:
19
19
  ActiveRecord 5:
20
20
 
21
21
  ```ruby
22
- gem 'second_level_cache', '~> 2.2.0'
22
+ gem 'second_level_cache', '~> 2.2.3'
23
23
  ```
24
24
 
25
25
  For ActiveRecord 4:
@@ -1,8 +1,9 @@
1
1
  module SecondLevelCache
2
2
  module ActiveRecord
3
3
  module Persistence
4
- def update_column(name, value)
5
- super(name, value).tap { update_second_level_cache }
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)
@@ -36,6 +36,10 @@ module RecordMarshal
36
36
  end
37
37
  end
38
38
 
39
+ klass.defined_enums.each do |key, value|
40
+ attributes[key] = value[attributes[key]]
41
+ end
42
+
39
43
  klass.instantiate(attributes)
40
44
  end
41
45
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SecondLevelCache
3
- VERSION = '2.2.2'.freeze
3
+ VERSION = '2.2.3'.freeze
4
4
  end
@@ -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.beta1', '< 5.1.0']
34
- gem.add_runtime_dependency 'activerecord', ['>= 5.0.0.beta1', '< 5.1.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
@@ -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.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-02-26 00:00:00.000000000 Z
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.beta1
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.beta1
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.beta1
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.beta1
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