validate presence of user on gpg_key

This commit is contained in:
Alexis Reigel 2017-07-05 14:03:36 +02:00
parent d9fd3709ab
commit e79e2ae1f4
2 changed files with 3 additions and 0 deletions

View File

@ -6,6 +6,8 @@ class GpgKey < ActiveRecord::Base
belongs_to :user
has_many :gpg_signatures, dependent: :nullify
validates :user, presence: true
validates :key,
presence: true,
uniqueness: true,

View File

@ -6,6 +6,7 @@ describe GpgKey do
end
describe "validation" do
it { is_expected.to validate_presence_of(:user) }
it { is_expected.to validate_presence_of(:key) }
it { is_expected.to validate_uniqueness_of(:key) }
it { is_expected.to allow_value("-----BEGIN PGP PUBLIC KEY BLOCK-----\nkey").for(:key) }