Commit 843b1de0 authored by Alexis Reigel's avatar Alexis Reigel

simplify nil handling

parent 14551424
...@@ -46,8 +46,7 @@ class GpgKey < ActiveRecord::Base ...@@ -46,8 +46,7 @@ class GpgKey < ActiveRecord::Base
end end
def key=(value) def key=(value)
value.strip! unless value.blank? super(value&.strip)
write_attribute(:key, value)
end end
def user_infos def user_infos
......
...@@ -44,6 +44,10 @@ describe GpgKey do ...@@ -44,6 +44,10 @@ describe GpgKey do
expect(described_class.new(key: " #{key} ").key).to eq(key) expect(described_class.new(key: " #{key} ").key).to eq(key)
end end
it 'does not strip when the key is nil' do
expect(described_class.new(key: nil).key).to be_nil
end
end end
describe '#user_infos' do describe '#user_infos' 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