提交 636b038e 编写于 作者: G Grzegorz Bizon

Only allow valid options when configuring tokens

上级 d31a3873
......@@ -48,6 +48,10 @@ module TokenAuthenticatableStrategies
end
def self.fabricate(instance, field, options)
if options[:digest] && options[:encrypted]
raise ArgumentError, 'Incompatible options set!'
end
if options[:digest]
TokenAuthenticatableStrategies::Digest.new(instance, field, options)
elsif options[:encrypted]
......
......@@ -28,6 +28,13 @@ describe TokenAuthenticatableStrategies::Base do
expect(strategy).to be_a TokenAuthenticatableStrategies::Insecure
end
end
context 'when incompatible options are provided' do
it 'raises an error' do
expect { described_class.fabricate(instance, field, digest: true, encrypted: true) }
.to raise_error ArgumentError
end
end
end
describe '#fallback?' do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册