Add clear_credentials method to ProjectImportData

This backports changes made in
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/9134.
This commit is contained in:
Stan Hu 2019-01-14 11:44:36 -08:00
parent 1a5de8955a
commit 27ba546ec8
2 changed files with 15 additions and 0 deletions

View file

@ -30,4 +30,8 @@ class ProjectImportData < ActiveRecord::Base
def merge_credentials(hash)
self.credentials = credentials.to_h.merge(hash) unless hash.empty?
end
def clear_credentials
self.credentials = {}
end
end

View file

@ -39,4 +39,15 @@ describe ProjectImportData do
expect(row.credentials).to eq({ 'number' => 10, 'foo' => 'bar' })
end
end
describe '#clear_credentials' do
it 'clears out the Hash' do
row = described_class.new
row.merge_credentials('number' => 10)
row.clear_credentials
expect(row.credentials).to eq({})
end
end
end