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
edge_type_class Types::BaseEdge
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)
end
......
......@@ -442,11 +442,10 @@ RSpec.describe Types::BaseObject do
expect(described_class.authorize).to be_nil
expect(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)
expect(read_only_type.authorize).to match_array [:write_only]
expect(inherited_read_only_type.authorize).to match_array [:write_only]
it 'can not redefine the authorize value' do
expect { read_only_type.authorize(:write_only) }.to raise_error('Cannot redefine authorize')
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