blob: 85fffcc167ba41f5af6d1ee50375e422b2518f05 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Abuse::TrustScore, feature_category: :instance_resiliency do
let_it_be(:user) { create(:user) }
let(:correlation_id) { nil }
let(:abuse_trust_score) do
create(:abuse_trust_score, user: user, correlation_id_value: correlation_id)
end
describe 'associations' do
it { is_expected.to belong_to(:user) }
end
describe 'validations' do
it { is_expected.to validate_presence_of(:user) }
it { is_expected.to validate_presence_of(:score) }
it { is_expected.to validate_presence_of(:source) }
end
describe 'create' do
subject { abuse_trust_score }
before do
allow(Labkit::Correlation::CorrelationId).to receive(:current_id).and_return('123abc')
end
context 'if correlation ID is nil' do
it 'adds the correlation id' do
expect(subject.correlation_id_value).to eq('123abc')
end
end
context 'if correlation ID is set' do
let(:correlation_id) { 'already-set' }
it 'does not change the correlation id' do
expect(subject.correlation_id_value).to eq('already-set')
end
end
end
end
|