Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
13f68f55
Commit
13f68f55
authored
May 14, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expect calls to read_attribute depending on cache presence
parent
f4810647
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
spec/models/concerns/redis_cacheable_spec.rb
spec/models/concerns/redis_cacheable_spec.rb
+8
-0
No files found.
spec/models/concerns/redis_cacheable_spec.rb
View file @
13f68f55
...
@@ -51,12 +51,16 @@ describe RedisCacheable do
...
@@ -51,12 +51,16 @@ describe RedisCacheable do
context
'when there is no cached value'
do
context
'when there is no cached value'
do
it
'reads the attribute'
do
it
'reads the attribute'
do
expect
(
instance
).
to
receive
(
:read_attribute
).
and_call_original
expect
(
subject
).
to
eq
(
payload
[
:name
])
expect
(
subject
).
to
eq
(
payload
[
:name
])
end
end
end
end
context
'when there is a cached value'
do
context
'when there is a cached value'
do
it
'reads the cached value'
do
it
'reads the cached value'
do
expect
(
instance
).
not_to
receive
(
:read_attribute
)
instance
.
cache_attributes
(
payload
)
instance
.
cache_attributes
(
payload
)
expect
(
subject
).
to
eq
(
payload
[
:name
])
expect
(
subject
).
to
eq
(
payload
[
:name
])
...
@@ -81,6 +85,8 @@ describe RedisCacheable do
...
@@ -81,6 +85,8 @@ describe RedisCacheable do
context
'when there is no cached value'
do
context
'when there is no cached value'
do
it
'reads the attribute'
do
it
'reads the attribute'
do
expect
(
instance
).
to
receive
(
:read_attribute
).
and_call_original
expect
(
subject
).
to
be_instance_of
(
ActiveSupport
::
TimeWithZone
)
expect
(
subject
).
to
be_instance_of
(
ActiveSupport
::
TimeWithZone
)
expect
(
subject
).
to
be_within
(
1
.
minute
).
of
(
Time
.
zone
.
now
)
expect
(
subject
).
to
be_within
(
1
.
minute
).
of
(
Time
.
zone
.
now
)
end
end
...
@@ -88,6 +94,8 @@ describe RedisCacheable do
...
@@ -88,6 +94,8 @@ describe RedisCacheable do
context
'when there is a cached value'
do
context
'when there is a cached value'
do
it
'reads the cached value'
do
it
'reads the cached value'
do
expect
(
instance
).
not_to
receive
(
:read_attribute
)
instance
.
cache_attributes
(
time:
Time
.
zone
.
now
)
instance
.
cache_attributes
(
time:
Time
.
zone
.
now
)
expect
(
subject
).
to
be_instance_of
(
ActiveSupport
::
TimeWithZone
)
expect
(
subject
).
to
be_instance_of
(
ActiveSupport
::
TimeWithZone
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment