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
b1fcac85
Commit
b1fcac85
authored
May 12, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make #cached_attr_reader and #cached_attr_time_reader specs Redis based
parent
20cfc3fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
8 deletions
+4
-8
spec/models/concerns/redis_cacheable_spec.rb
spec/models/concerns/redis_cacheable_spec.rb
+4
-8
No files found.
spec/models/concerns/redis_cacheable_spec.rb
View file @
b1fcac85
...
...
@@ -42,7 +42,7 @@ describe RedisCacheable do
end
end
describe
'#cached_attr_reader'
do
describe
'#cached_attr_reader'
,
:clean_gitlab_redis_shared_state
do
subject
{
instance
.
name
}
before
do
...
...
@@ -51,7 +51,6 @@ describe RedisCacheable do
context
'when there is no cached value'
do
it
'checks the cached value first then reads the attribute'
do
expect
(
instance
).
to
receive
(
:cached_attribute
).
and_return
(
nil
)
expect
(
instance
).
to
receive
(
:read_attribute
).
and_return
(
payload
[
:name
])
expect
(
subject
).
to
eq
(
payload
[
:name
])
...
...
@@ -60,15 +59,14 @@ describe RedisCacheable do
context
'when there is a cached value'
do
it
'reads the cached value'
do
expect
(
instance
).
to
receive
(
:cached_attribute
).
and_return
(
payload
[
:name
])
expect
(
instance
).
not_to
receive
(
:read_attribute
)
instance
.
cache_attributes
(
payload
)
expect
(
subject
).
to
eq
(
payload
[
:name
])
end
end
end
describe
'#cached_attr_time_reader'
do
describe
'#cached_attr_time_reader'
,
:clean_gitlab_redis_shared_state
do
subject
{
instance
.
time
}
before
do
...
...
@@ -77,7 +75,6 @@ describe RedisCacheable do
context
'when there is no cached value'
do
it
'checks the cached value first then reads the attribute'
do
expect
(
instance
).
to
receive
(
:cached_attribute
).
and_return
(
nil
)
expect
(
instance
).
to
receive
(
:read_attribute
).
and_return
(
Time
.
zone
.
now
)
expect
(
subject
).
to
be_instance_of
(
ActiveSupport
::
TimeWithZone
)
...
...
@@ -87,8 +84,7 @@ describe RedisCacheable do
context
'when there is a cached value'
do
it
'reads the cached value'
do
expect
(
instance
).
to
receive
(
:cached_attribute
).
and_return
(
Time
.
zone
.
now
.
to_s
)
expect
(
instance
).
not_to
receive
(
:read_attribute
)
instance
.
cache_attributes
(
time:
Time
.
zone
.
now
)
expect
(
subject
).
to
be_instance_of
(
ActiveSupport
::
TimeWithZone
)
expect
(
subject
).
to
be_within
(
1
.
minute
).
of
(
Time
.
zone
.
now
)
...
...
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