debian-mirror-gitlab/spec/models/commit_signatures/x509_commit_signature_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.5 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2022-01-26 12:08:38 +05:30
RSpec.describe CommitSignatures::X509CommitSignature do
2022-07-23 23:45:48 +05:30
# This commit is seeded from https://gitlab.com/gitlab-org/gitlab-test
# For instructions on how to add more seed data, see the project README
2022-10-11 01:57:18 +05:30
let_it_be(:commit_sha) { '189a6c924013fc3fe40d6f1ec1dc20214183bc97' }
let_it_be(:project) { create(:project, :public, :repository) }
let_it_be(:commit) { create(:commit, project: project, sha: commit_sha) }
let_it_be(:x509_certificate) { create(:x509_certificate) }
2020-03-13 15:44:24 +05:30
2020-05-24 23:13:21 +05:30
let(:attributes) do
{
commit_sha: commit_sha,
project: project,
x509_certificate_id: x509_certificate.id,
verification_status: "verified"
}
end
2022-10-11 01:57:18 +05:30
let(:signature) { create(:x509_commit_signature, commit_sha: commit_sha, x509_certificate: x509_certificate) }
2020-03-13 15:44:24 +05:30
it_behaves_like 'having unique enum values'
2022-07-23 23:45:48 +05:30
it_behaves_like 'commit signature'
2020-03-13 15:44:24 +05:30
describe 'validation' do
it { is_expected.to validate_presence_of(:x509_certificate_id) }
end
describe 'associations' do
it { is_expected.to belong_to(:x509_certificate).required }
end
2020-05-24 23:13:21 +05:30
describe '#user' do
context 'if email is assigned to a user' do
let!(:user) { create(:user, email: X509Helpers::User1.certificate_email) }
it 'returns user' do
expect(described_class.safe_create!(attributes).user).to eq(user)
end
end
it 'if email is not assigned to a user, return nil' do
expect(described_class.safe_create!(attributes).user).to be_nil
end
end
2020-03-13 15:44:24 +05:30
end