Add a JsonSerializationError class instead of raising SecurityError
This commit is contained in:
parent
2f92238a6e
commit
8d0ad36bcf
2 changed files with 6 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue