blob: 02527bf80bf44868f3c7c570c3926aa06dfc63b8 (
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
46
47
48
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Abuse::Event, type: :model, feature_category: :insider_threat do
let_it_be(:event) { create(:abuse_event) }
let_it_be(:user, reload: true) { create(:admin) }
subject { event }
it { is_expected.to be_valid }
describe "associations" do
it { is_expected.to belong_to(:user).class_name("User").inverse_of(:abuse_events) }
it { is_expected.to belong_to(:abuse_report).inverse_of(:abuse_events) }
end
describe "validations" do
it { is_expected.to validate_presence_of(:source) }
it { is_expected.to validate_presence_of(:category) }
it { is_expected.to validate_presence_of(:user).on(:create) }
end
describe 'enums' do
let(:categories) do
{
spam: 0, # spamcheck
virus: 1, # VirusTotal
fraud: 2, # Arkos, Telesign
ci_cd: 3 # PVS
}
end
let(:sources) do
{
spamcheck: 0,
virus_total: 1,
arkose_custom_score: 2,
arkose_global_score: 3,
telesign: 4,
pvs: 5
}
end
it { is_expected.to define_enum_for(:source).with_values(**sources) }
it { is_expected.to define_enum_for(:category).with_values(**categories) }
end
end
|