Commit e8b8693a authored by paz's avatar paz

Merge branch 'paz/prefixed-fingerprint' into 'master'

Tolerate 0x-prefix on fingerprints of subscriptions.

Closes #177

See merge request !54
parents 92456051 49a53284
......@@ -21,8 +21,10 @@ module Schleuder
end
def fingerprint=(arg)
# Strip whitespace from incoming arg.
write_attribute(:fingerprint, arg.to_s.gsub(/\s*/, '').chomp)
# Allow input to contain whitespace and '0x'-prefix, but don't store it
# into the DB.
value = arg.to_s.gsub(/\s*/, '').gsub(/^0x/, '').chomp
write_attribute(:fingerprint, value)
end
def key
......
......@@ -48,7 +48,7 @@ describe Schleuder::Subscription do
end
it "normalizes the fingerprint" do
fingerprint = " 99 991 1000 10"
fingerprint = "0x 99 991 1000 10"
subscription = build(:subscription, fingerprint: fingerprint)
expect(subscription.fingerprint).to eq "99991100010"
......
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