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
69dc893d
Commit
69dc893d
authored
Mar 20, 2019
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix spec for Gitlab::JsonCache
parent
bcc988a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
spec/lib/gitlab/json_cache_spec.rb
spec/lib/gitlab/json_cache_spec.rb
+23
-7
No files found.
spec/lib/gitlab/json_cache_spec.rb
View file @
69dc893d
...
@@ -146,6 +146,18 @@ describe Gitlab::JsonCache do
...
@@ -146,6 +146,18 @@ describe Gitlab::JsonCache do
expect
(
cache
.
read
(
key
,
BroadcastMessage
)).
to
be_nil
expect
(
cache
.
read
(
key
,
BroadcastMessage
)).
to
be_nil
end
end
it
'gracefully handles excluded fields from attributes during serialization'
do
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
and_return
(
broadcast_message
.
attributes
.
except
(
"message_html"
).
to_json
)
result
=
cache
.
read
(
key
,
BroadcastMessage
)
BroadcastMessage
.
cached_markdown_fields
.
html_fields
.
each
do
|
field
|
expect
(
result
.
public_send
(
field
)).
to
be_nil
end
end
end
end
context
'when the cached value is an array'
do
context
'when the cached value is an array'
do
...
@@ -327,7 +339,9 @@ describe Gitlab::JsonCache do
...
@@ -327,7 +339,9 @@ describe Gitlab::JsonCache do
.
with
(
expanded_key
)
.
with
(
expanded_key
)
.
and_return
(
'{'
)
.
and_return
(
'{'
)
expect
(
cache
.
read
(
key
,
BroadcastMessage
)).
to
be_nil
result
=
cache
.
fetch
(
key
,
as:
BroadcastMessage
)
{
'block result'
}
expect
(
result
).
to
eq
'block result'
end
end
it
'gracefully handles an empty hash'
do
it
'gracefully handles an empty hash'
do
...
@@ -335,7 +349,7 @@ describe Gitlab::JsonCache do
...
@@ -335,7 +349,7 @@ describe Gitlab::JsonCache do
.
with
(
expanded_key
)
.
with
(
expanded_key
)
.
and_return
(
'{}'
)
.
and_return
(
'{}'
)
expect
(
cache
.
read
(
key
,
BroadcastMessage
)).
to
be_a
(
BroadcastMessage
)
expect
(
cache
.
fetch
(
key
,
as:
BroadcastMessage
)).
to
be_a
(
BroadcastMessage
)
end
end
it
'gracefully handles unknown attributes'
do
it
'gracefully handles unknown attributes'
do
...
@@ -343,17 +357,19 @@ describe Gitlab::JsonCache do
...
@@ -343,17 +357,19 @@ describe Gitlab::JsonCache do
.
with
(
expanded_key
)
.
with
(
expanded_key
)
.
and_return
(
broadcast_message
.
attributes
.
merge
(
unknown_attribute:
1
).
to_json
)
.
and_return
(
broadcast_message
.
attributes
.
merge
(
unknown_attribute:
1
).
to_json
)
expect
(
cache
.
read
(
key
,
BroadcastMessage
)).
to
be_nil
result
=
cache
.
fetch
(
key
,
as:
BroadcastMessage
)
{
'block result'
}
expect
(
result
).
to
eq
'block result'
end
end
it
'gracefully handles excluded fields from attributes during serialization'
do
it
'gracefully handles excluded fields from attributes during serialization'
do
backend
.
write
(
expanded_key
,
broadcast_message
.
to_json
)
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
and_return
(
broadcast_message
.
attributes
.
except
(
"message_html"
).
to_json
)
result
=
cache
.
fetch
(
key
,
as:
BroadcastMessage
)
{
'block result'
}
result
=
cache
.
fetch
(
key
,
as:
BroadcastMessage
)
{
'block result'
}
excluded_fields
=
BroadcastMessage
.
cached_markdown_fields
.
html_fields
BroadcastMessage
.
cached_markdown_fields
.
html_fields
.
each
do
|
field
|
(
excluded_fields
+
[
'cached_markdown_version'
]).
each
do
|
field
|
expect
(
result
.
public_send
(
field
)).
to
be_nil
expect
(
result
.
public_send
(
field
)).
to
be_nil
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