Commit 8d0ad36b authored by Robert Speicher's avatar Robert Speicher

Add a JsonSerializationError class instead of raising SecurityError

parent 2f92238a
...@@ -5,8 +5,10 @@ ...@@ -5,8 +5,10 @@
module BlocksJsonSerialization module BlocksJsonSerialization
extend ActiveSupport::Concern extend ActiveSupport::Concern
def to_json(*args) JsonSerializationError = Class.new(StandardError)
raise SecurityError,
def to_json(*)
raise JsonSerializationError,
"JSON serialization has been disabled on #{self.class.name}" "JSON serialization has been disabled on #{self.class.name}"
end end
......
...@@ -7,11 +7,11 @@ describe BlocksJsonSerialization do ...@@ -7,11 +7,11 @@ describe BlocksJsonSerialization do
it 'blocks as_json' do it 'blocks as_json' do
expect { DummyModel.new.to_json } 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
it 'blocks to_json' do it 'blocks to_json' do
expect { DummyModel.new.to_json } 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
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