Commit 198aa993 authored by Robert Speicher's avatar Robert Speicher

Add a JsonSerializationError class instead of raising SecurityError

parent f905708f
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment