diff options
author | Rubén Dávila <ruben@gitlab.com> | 2017-10-05 02:44:49 +0300 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2017-10-05 16:26:02 +0300 |
commit | dd139e65b53f30eae2d8bb50dff180e8eab11fe4 (patch) | |
tree | 32411533b4ccfdfb6a2f08e2df0f2bb2b383e61d /spec/models/gpg_signature_spec.rb | |
parent | 2577cc99818bd0332aa78018de666579971341c8 (diff) |
Invalidate GpgSignatures associated to GpgKeySubkeys when revoking the GpgKey
Diffstat (limited to 'spec/models/gpg_signature_spec.rb')
-rw-r--r-- | spec/models/gpg_signature_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/models/gpg_signature_spec.rb b/spec/models/gpg_signature_spec.rb index 91d4efe8e2b..db033016c37 100644 --- a/spec/models/gpg_signature_spec.rb +++ b/spec/models/gpg_signature_spec.rb @@ -1,6 +1,9 @@ require 'rails_helper' RSpec.describe GpgSignature do + let(:gpg_key) { create(:gpg_key) } + let(:gpg_key_subkey) { create(:gpg_key_subkey) } + describe 'associations' do it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:gpg_key) } @@ -26,4 +29,26 @@ RSpec.describe GpgSignature do gpg_signature.commit end end + + describe '#gpg_key=' do + it 'supports the assignment of a GpgKey' do + gpg_signature = create(:gpg_signature, gpg_key: gpg_key) + + expect(gpg_signature.gpg_key).to be_an_instance_of(GpgKey) + end + + it 'supports the assignment of a GpgKeySubkey' do + gpg_signature = create(:gpg_signature, gpg_key: gpg_key_subkey) + + expect(gpg_signature.gpg_key).to be_an_instance_of(GpgKeySubkey) + end + + it 'clears gpg_key and gpg_key_subkey_id when passing nil' do + gpg_signature = create(:gpg_signature, gpg_key: gpg_key_subkey) + gpg_signature.update_attribute(:gpg_key, nil) + + expect(gpg_signature.gpg_key_id).to be_nil + expect(gpg_signature.gpg_key_subkey_id).to be_nil + end + end end |