Commit 1e126638 authored by Alex Kalderimis's avatar Alex Kalderimis Committed by Brett Walker

Freeze the authorize value to prevent changes

parent c153ce12
...@@ -10,7 +10,9 @@ module Types ...@@ -10,7 +10,9 @@ module Types
edge_type_class Types::BaseEdge edge_type_class Types::BaseEdge
def self.authorize(*args) def self.authorize(*args)
@authorize_args = args if args.any? raise 'Cannot redefine authorize' if @authorize_args && args.any?
@authorize_args = args.freeze if args.any?
@authorize_args || (superclass.respond_to?(:authorize) ? superclass.authorize : nil) @authorize_args || (superclass.respond_to?(:authorize) ? superclass.authorize : nil)
end end
......
...@@ -442,11 +442,10 @@ RSpec.describe Types::BaseObject do ...@@ -442,11 +442,10 @@ RSpec.describe Types::BaseObject do
expect(described_class.authorize).to be_nil expect(described_class.authorize).to be_nil
expect(read_only_type.authorize).to match_array [:read_only] expect(read_only_type.authorize).to match_array [:read_only]
expect(inherited_read_only_type.authorize).to match_array [:read_only] expect(inherited_read_only_type.authorize).to match_array [:read_only]
end
read_only_type.authorize(:write_only) it 'can not redefine the authorize value' do
expect { read_only_type.authorize(:write_only) }.to raise_error('Cannot redefine authorize')
expect(read_only_type.authorize).to match_array [:write_only]
expect(inherited_read_only_type.authorize).to match_array [:write_only]
end end
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