Commit 636b038e authored by Grzegorz Bizon's avatar Grzegorz Bizon

Only allow valid options when configuring tokens

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