garner 0.5.0 → 0.5.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/.rubocop.yml +1 -30
- data/.rubocop_todo.yml +49 -0
- data/.travis.yml +2 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/README.md +2 -2
- data/garner.gemspec +2 -2
- data/lib/garner/cache.rb +1 -1
- data/lib/garner/strategies/binding/key/binding_index.rb +1 -1
- data/lib/garner/version.rb +1 -1
- data/spec/garner/cache/context_spec.rb +4 -4
- data/spec/garner/cache/identity_spec.rb +6 -6
- data/spec/garner/cache_spec.rb +14 -6
- data/spec/garner/config_spec.rb +1 -1
- data/spec/garner/mixins/mongoid/document_spec.rb +12 -12
- data/spec/garner/mixins/mongoid/identity_spec.rb +25 -25
- data/spec/garner/mixins/rack_spec.rb +6 -6
- data/spec/garner/strategies/binding/invalidation/binding_index_spec.rb +1 -1
- data/spec/garner/strategies/binding/invalidation/touch_spec.rb +3 -3
- data/spec/garner/strategies/binding/key/binding_index_spec.rb +44 -44
- data/spec/garner/strategies/binding/key/cache_key_spec.rb +2 -2
- data/spec/garner/strategies/binding/key/safe_cache_key_spec.rb +12 -12
- data/spec/garner/strategies/context/key/caller_spec.rb +17 -17
- data/spec/garner/strategies/context/key/jsonp_spec.rb +2 -2
- data/spec/garner/strategies/context/key/request_get_spec.rb +3 -3
- data/spec/garner/strategies/context/key/request_path_spec.rb +3 -3
- data/spec/garner/strategies/context/key/request_post_spec.rb +3 -3
- data/spec/garner/version_spec.rb +2 -2
- data/spec/integration/active_record_spec.rb +4 -4
- data/spec/integration/grape_spec.rb +1 -1
- data/spec/integration/mongoid_spec.rb +57 -57
- data/spec/integration/rack_spec.rb +7 -7
- data/spec/integration/sinatra_spec.rb +1 -1
- data/spec/shared/binding_invalidation_strategy.rb +1 -1
- data/spec/shared/binding_key_strategy.rb +4 -4
- data/spec/shared/conditional_get.rb +13 -13
- data/spec/shared/context_key_strategy.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be2617701ad4ec815fb797f21249d19df49c35d5
|
4
|
+
data.tar.gz: 3b5dca339f0b0aa5926bd4dd210c58c90ec7c658
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4df4d8bed3cb46aad815fb29fafa791e2f786521ca76849eef16bad67d7da54e52076f85a13c36811a9ca6750813b41cff7e85c3e2b5ae64d5c03b4e953fe7ed
|
7
|
+
data.tar.gz: 20ef731da18baf1e571977e3144b4a7aa28d51dee40931260b7c0de8121601ee4d621300248d8bca7eea6c653cac06c9726b55e0b4aa1b1ba1289e1f23588556
|
data/.rubocop.yml
CHANGED
@@ -2,34 +2,5 @@ AllCops:
|
|
2
2
|
Exclude:
|
3
3
|
- vendor/**/*
|
4
4
|
|
5
|
-
|
6
|
-
Enabled: false
|
5
|
+
inherit_from: .rubocop_todo.yml
|
7
6
|
|
8
|
-
MethodLength:
|
9
|
-
Enabled: false
|
10
|
-
|
11
|
-
ClassLength:
|
12
|
-
Enabled: false
|
13
|
-
|
14
|
-
CyclomaticComplexity:
|
15
|
-
Enabled: false
|
16
|
-
|
17
|
-
Documentation:
|
18
|
-
# don't require classes to be documented
|
19
|
-
Enabled: false
|
20
|
-
|
21
|
-
Encoding:
|
22
|
-
# no need to always specify encoding
|
23
|
-
Enabled: false
|
24
|
-
|
25
|
-
DoubleNegation:
|
26
|
-
Enabled: false
|
27
|
-
|
28
|
-
RaiseArgs:
|
29
|
-
Enabled: false
|
30
|
-
|
31
|
-
RescueModifier:
|
32
|
-
Enabled: false
|
33
|
-
|
34
|
-
ModuleFunction:
|
35
|
-
Enabled: false
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2014-11-26 10:49:30 -0500 using RuboCop version 0.27.1.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
# Offense count: 3
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Max: 33
|
11
|
+
|
12
|
+
# Offense count: 2
|
13
|
+
Metrics/CyclomaticComplexity:
|
14
|
+
Max: 11
|
15
|
+
|
16
|
+
# Offense count: 56
|
17
|
+
# Configuration parameters: AllowURI, URISchemes.
|
18
|
+
Metrics/LineLength:
|
19
|
+
Max: 140
|
20
|
+
|
21
|
+
# Offense count: 3
|
22
|
+
# Configuration parameters: CountComments.
|
23
|
+
Metrics/MethodLength:
|
24
|
+
Max: 24
|
25
|
+
|
26
|
+
# Offense count: 1
|
27
|
+
Metrics/PerceivedComplexity:
|
28
|
+
Max: 12
|
29
|
+
|
30
|
+
# Offense count: 38
|
31
|
+
Style/Documentation:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
# Offense count: 3
|
35
|
+
Style/DoubleNegation:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
# Offense count: 1
|
39
|
+
Style/ModuleFunction:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
# Offense count: 1
|
43
|
+
# Configuration parameters: SupportedStyles.
|
44
|
+
Style/RaiseArgs:
|
45
|
+
EnforcedStyle: compact
|
46
|
+
|
47
|
+
# Offense count: 1
|
48
|
+
Style/RescueModifier:
|
49
|
+
Enabled: false
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
0.5.1 (11/26/2014)
|
2
|
+
------------------
|
3
|
+
|
4
|
+
* Fixed [#81](https://github.com/artsy/garner/issues/81): `Garner.cache` loses namespace options when calling delete when cache block yields `nil` - [@dblock](https://github.com/dblock).
|
5
|
+
* Upgraded RSpec to 3.x and RuboCop to 0.27.1 - [@dblock](https://github.com/dblock).
|
6
|
+
|
1
7
|
0.5.0 (7/17/2014)
|
2
8
|
-----------------
|
3
9
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -8,7 +8,7 @@ If you're not familiar with HTTP caching, ETags and If-Modified-Since, watch us
|
|
8
8
|
Upgrading
|
9
9
|
---------
|
10
10
|
|
11
|
-
The current stable release line of Garner is 0.
|
11
|
+
The current stable release line of Garner is 0.5.x, and contains many breaking changes from the previous 0.3.x series. For a summary of important changes, see [UPGRADING](UPGRADING.md).
|
12
12
|
|
13
13
|
Usage
|
14
14
|
-----
|
@@ -90,7 +90,7 @@ end
|
|
90
90
|
In the above example, the `Order.identify` call will not result in a database query. Instead, it just communicates to Garner's cache sweeper that whenever the order with identity `params[:id]` is updated, this cache result should be invalidated. The `identify` method is provided by the Mongoid mixin. To use it, you should configure `Garner.config.mongoid_identity_fields`, e.g.:
|
91
91
|
|
92
92
|
```ruby
|
93
|
-
Garner.configure
|
93
|
+
Garner.configure do |config|
|
94
94
|
config.mongoid_identity_fields = [:_id, :_slugs]
|
95
95
|
end
|
96
96
|
```
|
data/garner.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_runtime_dependency 'activesupport'
|
24
24
|
|
25
25
|
s.add_development_dependency 'rake'
|
26
|
-
s.add_development_dependency 'rspec', '~>
|
26
|
+
s.add_development_dependency 'rspec', '~> 3.1'
|
27
27
|
s.add_development_dependency 'bundler'
|
28
28
|
s.add_development_dependency 'grape', '~> 0.8.0'
|
29
29
|
s.add_development_dependency 'sinatra'
|
@@ -40,5 +40,5 @@ Gem::Specification.new do |s|
|
|
40
40
|
s.add_development_dependency 'coveralls'
|
41
41
|
s.add_development_dependency 'yard'
|
42
42
|
s.add_development_dependency 'dalli'
|
43
|
-
s.add_development_dependency 'rubocop', '0.
|
43
|
+
s.add_development_dependency 'rubocop', '0.27.1'
|
44
44
|
end
|
data/lib/garner/cache.rb
CHANGED
@@ -13,7 +13,7 @@ module Garner
|
|
13
13
|
result = Garner.config.cache.fetch(compound_key, options_hash) do
|
14
14
|
yield
|
15
15
|
end
|
16
|
-
Garner.config.cache.delete(compound_key) unless result
|
16
|
+
Garner.config.cache.delete(compound_key, options_hash) unless result
|
17
17
|
else
|
18
18
|
result = yield
|
19
19
|
end
|
@@ -84,7 +84,7 @@ module Garner
|
|
84
84
|
def self.canonical?(binding)
|
85
85
|
# TODO: Implement real logic for determining canonicity.
|
86
86
|
binding.is_a?(Mongoid::Document) ||
|
87
|
-
|
87
|
+
(binding.is_a?(Class) && binding.include?(Mongoid::Document))
|
88
88
|
end
|
89
89
|
|
90
90
|
def self.index_key_for(binding)
|
data/lib/garner/version.rb
CHANGED
@@ -16,22 +16,22 @@ describe Garner::Cache::Context do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'returns a Garner::Cache::Identity' do
|
19
|
-
subject.call.
|
19
|
+
expect(subject.call).to be_a(Garner::Cache::Identity)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "sets the identity's ruby_binding to self" do
|
23
|
-
subject.call.ruby_context.
|
23
|
+
expect(subject.call.ruby_context).to eq @test_context
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'applies each of Garner.config.context_key_strategies' do
|
27
27
|
# Default :context_key_strategies
|
28
|
-
subject.call.key_hash[:caller].
|
28
|
+
expect(subject.call.key_hash[:caller]).not_to be_nil
|
29
29
|
|
30
30
|
# Custom :context_key_strategies
|
31
31
|
Garner.configure do |config|
|
32
32
|
config.context_key_strategies = []
|
33
33
|
end
|
34
|
-
subject.call.key_hash[:caller].
|
34
|
+
expect(subject.call.key_hash[:caller]).to be_nil
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -4,17 +4,17 @@ describe Garner::Cache::Identity do
|
|
4
4
|
|
5
5
|
it 'includes Garner.config.global_cache_options' do
|
6
6
|
Garner.configure { |config| config.global_cache_options = { foo: 'bar' } }
|
7
|
-
subject.options_hash[:foo].
|
7
|
+
expect(subject.options_hash[:foo]).to eq 'bar'
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'includes Garner.config.expires_in' do
|
11
11
|
Garner.configure { |config| config.expires_in = 5.minutes }
|
12
|
-
subject.options_hash[:expires_in].
|
12
|
+
expect(subject.options_hash[:expires_in]).to eq 5.minutes
|
13
13
|
end
|
14
14
|
|
15
15
|
describe 'nocache' do
|
16
16
|
it 'forces a cache bypass' do
|
17
|
-
Garner::Cache.
|
17
|
+
expect(Garner::Cache).not_to receive :fetch
|
18
18
|
subject.nocache.fetch { 'foo' }
|
19
19
|
end
|
20
20
|
end
|
@@ -23,7 +23,7 @@ describe Garner::Cache::Identity do
|
|
23
23
|
it "adds to the object identity's bindings" do
|
24
24
|
subject.bind('foo')
|
25
25
|
subject.bind('bar')
|
26
|
-
subject.bindings.
|
26
|
+
expect(subject.bindings).to eq %w(foo bar)
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'raises an error for <> 1 arguments' do
|
@@ -36,7 +36,7 @@ describe Garner::Cache::Identity do
|
|
36
36
|
it "adds to the object identity's key_hash" do
|
37
37
|
subject.key(foo: 1)
|
38
38
|
subject.key(bar: 2)
|
39
|
-
subject.key_hash.
|
39
|
+
expect(subject.key_hash).to eq(foo: 1, bar: 2)
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'raises an error for <> 1 arguments' do
|
@@ -53,7 +53,7 @@ describe Garner::Cache::Identity do
|
|
53
53
|
it "adds to the object identity's options_hash" do
|
54
54
|
subject.options(foo: 1)
|
55
55
|
subject.options(bar: 2)
|
56
|
-
subject.options_hash.
|
56
|
+
expect(subject.options_hash).to eq(expires_in: nil, foo: 1, bar: 2)
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'raises an error for <> 1 arguments' do
|
data/spec/garner/cache_spec.rb
CHANGED
@@ -21,18 +21,18 @@ describe Garner::Cache do
|
|
21
21
|
result2 = subject.fetch([], {}, {}) { 'foo' }
|
22
22
|
result3 = subject.fetch([], {}, {}) { 'bar' }
|
23
23
|
|
24
|
-
result1.
|
25
|
-
result2.
|
26
|
-
result3.
|
24
|
+
expect(result1).to be nil
|
25
|
+
expect(result2).to eq 'foo'
|
26
|
+
expect(result3).to eq 'foo'
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'does not cache results with un-bindable bindings' do
|
30
30
|
unbindable = double('object')
|
31
|
-
unbindable.
|
31
|
+
allow(unbindable).to receive(:garner_cache_key) { nil }
|
32
32
|
result1 = subject.fetch([unbindable], {}, {}) { 'foo' }
|
33
33
|
result2 = subject.fetch([unbindable], {}, {}) { 'bar' }
|
34
|
-
result1.
|
35
|
-
result2.
|
34
|
+
expect(result1).to eq 'foo'
|
35
|
+
expect(result2).to eq 'bar'
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'raises an exception by default for nil bindings' do
|
@@ -45,5 +45,13 @@ describe Garner::Cache do
|
|
45
45
|
Garner.configure { |config| config.whiny_nils = false }
|
46
46
|
expect { subject.fetch([nil], {}, {}) { 'foo' } }.not_to raise_error
|
47
47
|
end
|
48
|
+
|
49
|
+
it 'deletes record when cached block yields nil' do
|
50
|
+
binding = double('object', garner_cache_key: 'key')
|
51
|
+
expect(Garner.config.cache).to receive(:delete).with({ binding_keys: ['key'], context_keys: { key: 'value' } }, { namespace: 'foo' })
|
52
|
+
subject.fetch [binding], { key: 'value' }, namespace: 'foo' do
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
end
|
48
56
|
end
|
49
57
|
end
|
data/spec/garner/config_spec.rb
CHANGED
@@ -14,8 +14,8 @@ describe Garner::Mixins::Mongoid::Document do
|
|
14
14
|
|
15
15
|
describe 'proxied_classes' do
|
16
16
|
it 'returns all Mongoid superclasses' do
|
17
|
-
@monger.proxied_classes.
|
18
|
-
@cheese.proxied_classes.
|
17
|
+
expect(@monger.proxied_classes).to eq [Monger]
|
18
|
+
expect(@cheese.proxied_classes).to eq [Cheese, Food]
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -26,44 +26,44 @@ describe Garner::Mixins::Mongoid::Document do
|
|
26
26
|
describe '_latest_by_updated_at' do
|
27
27
|
it 'returns a Mongoid::Document instance' do
|
28
28
|
subject.create
|
29
|
-
subject.send(:_latest_by_updated_at).
|
29
|
+
expect(subject.send(:_latest_by_updated_at)).to be_a(subject)
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'returns the _latest_by_updated_at document by :updated_at' do
|
33
33
|
mongers = 3.times.map { |i| subject.create(name: "M#{i}") }
|
34
34
|
mongers[1].touch
|
35
35
|
|
36
|
-
subject.send(:_latest_by_updated_at)._id.
|
37
|
-
subject.send(:_latest_by_updated_at).updated_at.
|
36
|
+
expect(subject.send(:_latest_by_updated_at)._id).to eq mongers[1]._id
|
37
|
+
expect(subject.send(:_latest_by_updated_at).updated_at).to eq mongers[1].reload.updated_at
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'returns nil if there are no documents' do
|
41
|
-
subject.send(:_latest_by_updated_at).
|
41
|
+
expect(subject.send(:_latest_by_updated_at)).to be_nil
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'returns nil if updated_at does not exist' do
|
45
45
|
subject.create
|
46
|
-
subject.
|
47
|
-
subject.send(:_latest_by_updated_at).
|
46
|
+
allow(subject).to receive(:fields) { {} }
|
47
|
+
expect(subject.send(:_latest_by_updated_at)).to be_nil
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
describe 'proxy_binding' do
|
52
52
|
it 'returns the _latest_by_updated_at document' do
|
53
53
|
subject.create
|
54
|
-
subject.proxy_binding.
|
54
|
+
expect(subject.proxy_binding).to be_a(Monger)
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'responds to :touch' do
|
58
58
|
subject.create
|
59
|
-
subject.
|
59
|
+
expect_any_instance_of(subject).to receive(:touch)
|
60
60
|
subject.proxy_binding.touch
|
61
61
|
end
|
62
62
|
|
63
63
|
describe 'cache_key' do
|
64
64
|
it 'matches what would be returned from the full object' do
|
65
65
|
monger = subject.create
|
66
|
-
subject.proxy_binding.cache_key.
|
66
|
+
expect(subject.proxy_binding.cache_key).to eq monger.reload.cache_key
|
67
67
|
end
|
68
68
|
|
69
69
|
context 'with Mongoid subclasses' do
|
@@ -71,7 +71,7 @@ describe Garner::Mixins::Mongoid::Document do
|
|
71
71
|
|
72
72
|
it 'matches what would be returned from the full object' do
|
73
73
|
cheese = subject.create
|
74
|
-
subject.proxy_binding.cache_key.
|
74
|
+
expect(subject.proxy_binding.cache_key).to eq cheese.reload.cache_key
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -4,9 +4,9 @@ require 'garner/mixins/mongoid'
|
|
4
4
|
describe Garner::Mixins::Mongoid::Identity do
|
5
5
|
before(:each) do
|
6
6
|
@mock_strategy = double('strategy')
|
7
|
-
@mock_strategy.
|
7
|
+
allow(@mock_strategy).to receive(:apply)
|
8
8
|
@mock_mongoid_strategy = double('mongoid_strategy')
|
9
|
-
@mock_mongoid_strategy.
|
9
|
+
allow(@mock_mongoid_strategy).to receive(:apply)
|
10
10
|
end
|
11
11
|
|
12
12
|
describe 'from_class_and_handle' do
|
@@ -36,9 +36,9 @@ describe Garner::Mixins::Mongoid::Identity do
|
|
36
36
|
|
37
37
|
it 'sets klass, handle and a conditions hash' do
|
38
38
|
identity = subject.from_class_and_handle(Monger, 'id')
|
39
|
-
identity.klass.
|
40
|
-
identity.handle.
|
41
|
-
identity.conditions['$or'].
|
39
|
+
expect(identity.klass).to eq Monger
|
40
|
+
expect(identity.handle).to eq 'id'
|
41
|
+
expect(identity.conditions['$or']).to eq [
|
42
42
|
{ _id: 'id' },
|
43
43
|
{ _slugs: 'id' }
|
44
44
|
]
|
@@ -47,9 +47,9 @@ describe Garner::Mixins::Mongoid::Identity do
|
|
47
47
|
context 'on a Mongoid subclass' do
|
48
48
|
it 'sets klass to parent and includes the _type field' do
|
49
49
|
identity = subject.from_class_and_handle(Cheese, 'id')
|
50
|
-
identity.klass.
|
51
|
-
identity.conditions[:_type].
|
52
|
-
identity.conditions['$or'].
|
50
|
+
expect(identity.klass).to eq Cheese
|
51
|
+
expect(identity.conditions[:_type]).to eq('$in' => ['Cheese'])
|
52
|
+
expect(identity.conditions['$or']).to eq [
|
53
53
|
{ _id: 'id' },
|
54
54
|
{ _slugs: 'id' }
|
55
55
|
]
|
@@ -61,17 +61,17 @@ describe Garner::Mixins::Mongoid::Identity do
|
|
61
61
|
subject { Monger.identify('m1').to_s }
|
62
62
|
|
63
63
|
it 'stringizes the binding and includes klass and handle' do
|
64
|
-
subject.
|
65
|
-
subject.
|
66
|
-
subject.
|
64
|
+
expect(subject).to be_a(String)
|
65
|
+
expect(subject).to match(/Monger/)
|
66
|
+
expect(subject).to match(/m1/)
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should not change across identical instances' do
|
70
|
-
subject.
|
70
|
+
expect(subject).to eq Monger.identify('m1').to_s
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should be different across different instances' do
|
74
|
-
subject.
|
74
|
+
expect(subject).not_to eq(Monger.identify('m2').to_s)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -88,26 +88,26 @@ describe Garner::Mixins::Mongoid::Identity do
|
|
88
88
|
|
89
89
|
describe 'proxy_binding' do
|
90
90
|
it 'returns nil for nonexistent bindings' do
|
91
|
-
Monger.identify('m2').proxy_binding.
|
91
|
+
expect(Monger.identify('m2').proxy_binding).to be_nil
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'returns nil for nil bindings' do
|
95
95
|
@monger.unset(:_slugs)
|
96
|
-
Monger.identify(nil).proxy_binding.
|
96
|
+
expect(Monger.identify(nil).proxy_binding).to be_nil
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'limits the query' do
|
100
|
-
Mongoid::Slug::Criteria.
|
100
|
+
expect_any_instance_of(Mongoid::Slug::Criteria).to receive(:limit).with(1).and_return([@monger])
|
101
101
|
Monger.identify('m1').proxy_binding
|
102
102
|
end
|
103
103
|
|
104
104
|
describe 'cache_key' do
|
105
105
|
it "generates a cache key equal to Mongoid::Document's" do
|
106
|
-
Monger.identify('m1').proxy_binding.cache_key.
|
106
|
+
expect(Monger.identify('m1').proxy_binding.cache_key).to eq @monger.cache_key
|
107
107
|
|
108
108
|
# Also test for Mongoid subclasses
|
109
|
-
Cheese.identify('havarti').proxy_binding.cache_key.
|
110
|
-
Food.identify(@cheese.id).proxy_binding.cache_key.
|
109
|
+
expect(Cheese.identify('havarti').proxy_binding.cache_key).to eq @cheese.cache_key
|
110
|
+
expect(Food.identify(@cheese.id).proxy_binding.cache_key).to eq @cheese.cache_key
|
111
111
|
end
|
112
112
|
|
113
113
|
context 'without Mongoid::Timestamps' do
|
@@ -117,22 +117,22 @@ describe Garner::Mixins::Mongoid::Identity do
|
|
117
117
|
end
|
118
118
|
|
119
119
|
it "generates a cache key equal to Mongoid::Document's" do
|
120
|
-
Monger.identify('m1').proxy_binding.cache_key.
|
120
|
+
expect(Monger.identify('m1').proxy_binding.cache_key).to eq @monger.cache_key
|
121
121
|
|
122
122
|
# Also test for Mongoid subclasses
|
123
|
-
Cheese.identify('havarti').proxy_binding.cache_key.
|
124
|
-
Food.identify(@cheese.id).proxy_binding.cache_key.
|
123
|
+
expect(Cheese.identify('havarti').proxy_binding.cache_key).to eq @cheese.cache_key
|
124
|
+
expect(Food.identify(@cheese.id).proxy_binding.cache_key).to eq @cheese.cache_key
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
129
|
describe 'updated_at' do
|
130
130
|
it "returns :updated_at equal to Mongoid::Document's" do
|
131
|
-
Monger.identify('m1').proxy_binding.updated_at.
|
131
|
+
expect(Monger.identify('m1').proxy_binding.updated_at).to eq Monger.find('m1').updated_at
|
132
132
|
|
133
133
|
# Also test for Mongoid subclasses
|
134
|
-
Cheese.identify('havarti').proxy_binding.updated_at.
|
135
|
-
Food.identify(@cheese.id).proxy_binding.updated_at.
|
134
|
+
expect(Cheese.identify('havarti').proxy_binding.updated_at).to eq @cheese.updated_at
|
135
|
+
expect(Food.identify(@cheese.id).proxy_binding.updated_at).to eq @cheese.updated_at
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|