diff options
author | Rubén Dávila <ruben@gitlab.com> | 2017-09-28 13:26:16 -0500 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2017-10-05 08:25:27 -0500 |
commit | b27549df97151f773c6fbfac4c9dc3aa491a8b5d (patch) | |
tree | 2eeb19000452adf02914e583020d9e024327ac2d /spec/models | |
parent | 4b6d045c0c3c8d8ab70dd80feb960f193e498d7a (diff) | |
download | gitlab-ce-b27549df97151f773c6fbfac4c9dc3aa491a8b5d.tar.gz |
Add some basic specs and refactor model and validations
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/gpg_key_spec.rb | 9 | ||||
-rw-r--r-- | spec/models/gpg_key_subkey_spec.rb | 15 |
2 files changed, 24 insertions, 0 deletions
diff --git a/spec/models/gpg_key_spec.rb b/spec/models/gpg_key_spec.rb index 743f2cfcab5..69d6090e034 100644 --- a/spec/models/gpg_key_spec.rb +++ b/spec/models/gpg_key_spec.rb @@ -3,6 +3,7 @@ require 'rails_helper' describe GpgKey do describe "associations" do it { is_expected.to belong_to(:user) } + it { is_expected.to have_many(:subkeys) } end describe "validation" do @@ -38,6 +39,14 @@ describe GpgKey do expect(gpg_key.primary_keyid).to eq GpgHelpers::User1.primary_keyid end end + + describe 'generate_subkeys' do + it 'extracts the subkeys from the gpg key' do + gpg_key = create(:gpg_key, key: GpgHelpers::User1.public_key_with_extra_signing_key) + + expect(gpg_key.subkeys.count).to eq(2) + end + end end describe '#key=' do diff --git a/spec/models/gpg_key_subkey_spec.rb b/spec/models/gpg_key_subkey_spec.rb new file mode 100644 index 00000000000..3c86837f47f --- /dev/null +++ b/spec/models/gpg_key_subkey_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +describe GpgKeySubkey do + subject { build(:gpg_key_subkey) } + + describe 'associations' do + it { is_expected.to belong_to(:gpg_key) } + end + + describe 'validations' do + it { is_expected.to validate_presence_of(:gpg_key_id) } + it { is_expected.to validate_presence_of(:fingerprint) } + it { is_expected.to validate_presence_of(:keyid) } + end +end |