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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
2c29e80a
Commit
2c29e80a
authored
May 14, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for exact time matches
parent
13f68f55
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
spec/models/concerns/redis_cacheable_spec.rb
spec/models/concerns/redis_cacheable_spec.rb
+8
-6
No files found.
spec/models/concerns/redis_cacheable_spec.rb
View file @
2c29e80a
...
@@ -79,6 +79,8 @@ describe RedisCacheable do
...
@@ -79,6 +79,8 @@ describe RedisCacheable do
describe
'#cached_attr_time_reader'
,
:clean_gitlab_redis_shared_state
do
describe
'#cached_attr_time_reader'
,
:clean_gitlab_redis_shared_state
do
subject
{
instance
.
time
}
subject
{
instance
.
time
}
let
(
:other_time
)
{
Time
.
zone
.
parse
(
'May 14 2018'
)
}
before
do
before
do
model
.
cached_attr_time_reader
(
:time
)
model
.
cached_attr_time_reader
(
:time
)
end
end
...
@@ -88,7 +90,7 @@ describe RedisCacheable do
...
@@ -88,7 +90,7 @@ describe RedisCacheable do
expect
(
instance
).
to
receive
(
:read_attribute
).
and_call_original
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
eq
(
payload
[
:time
]
)
end
end
end
end
...
@@ -96,19 +98,19 @@ describe RedisCacheable do
...
@@ -96,19 +98,19 @@ describe RedisCacheable do
it
'reads the cached value'
do
it
'reads the cached value'
do
expect
(
instance
).
not_to
receive
(
:read_attribute
)
expect
(
instance
).
not_to
receive
(
:read_attribute
)
instance
.
cache_attributes
(
time:
Time
.
zone
.
now
)
instance
.
cache_attributes
(
time:
other_time
)
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
eq
(
other_time
)
end
end
end
end
it
'always returns the latest values'
do
it
'always returns the latest values'
do
expect
(
instance
.
time
).
to
be_within
(
1
.
minute
).
of
(
Time
.
zone
.
now
)
expect
(
instance
.
time
).
to
eq
(
payload
[
:time
]
)
instance
.
cache_attributes
(
time:
1
.
hour
.
ago
)
instance
.
cache_attributes
(
time:
other_time
)
expect
(
instance
.
time
).
to
be_within
(
1
.
minute
).
of
(
1
.
hour
.
ago
)
expect
(
instance
.
time
).
to
eq
(
other_time
)
end
end
end
end
end
end
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