debian-mirror-gitlab/spec/models/alerting/project_alerting_setting_spec.rb

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

41 lines
944 B
Ruby
Raw Permalink Normal View History

2020-04-22 19:07:51 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Alerting::ProjectAlertingSetting do
2020-04-22 19:07:51 +05:30
let_it_be(:project) { create(:project) }
subject { create(:project_alerting_setting, project: project) }
describe 'Associations' do
it { is_expected.to belong_to(:project) }
end
describe '#token' do
context 'when set' do
let(:token) { SecureRandom.hex }
subject do
create(:project_alerting_setting, project: project, token: token)
end
it 'reads the token' do
expect(subject.token).to eq(token)
expect(subject.encrypted_token).not_to be_nil
expect(subject.encrypted_token_iv).not_to be_nil
end
end
context 'when not set' do
before do
subject.token = nil
end
it 'generates a token before validation' do
expect(subject).to be_valid
expect(subject.token).to match(/\A\h{32}\z/)
end
end
end
end