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
Boxiang Sun
gitlab-ce
Commits
8d0ad36b
Commit
8d0ad36b
authored
Dec 01, 2017
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a JsonSerializationError class instead of raising SecurityError
parent
2f92238a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
app/models/concerns/blocks_json_serialization.rb
app/models/concerns/blocks_json_serialization.rb
+4
-2
spec/models/concerns/blocks_json_serialization_spec.rb
spec/models/concerns/blocks_json_serialization_spec.rb
+2
-2
No files found.
app/models/concerns/blocks_json_serialization.rb
View file @
8d0ad36b
...
...
@@ -5,8 +5,10 @@
module
BlocksJsonSerialization
extend
ActiveSupport
::
Concern
def
to_json
(
*
args
)
raise
SecurityError
,
JsonSerializationError
=
Class
.
new
(
StandardError
)
def
to_json
(
*
)
raise
JsonSerializationError
,
"JSON serialization has been disabled on
#{
self
.
class
.
name
}
"
end
...
...
spec/models/concerns/blocks_json_serialization_spec.rb
View file @
8d0ad36b
...
...
@@ -7,11 +7,11 @@ describe BlocksJsonSerialization do
it
'blocks as_json'
do
expect
{
DummyModel
.
new
.
to_json
}
.
to
raise_error
(
SecurityError
,
"JSON serialization has been disabled on DummyModel"
)
.
to
raise_error
(
described_class
::
JsonSerializationError
,
/DummyModel/
)
end
it
'blocks to_json'
do
expect
{
DummyModel
.
new
.
to_json
}
.
to
raise_error
(
SecurityError
,
"JSON serialization has been disabled on DummyModel"
)
.
to
raise_error
(
described_class
::
JsonSerializationError
,
/DummyModel/
)
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