Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/abuse/event_spec.rb')
-rw-r--r--spec/models/abuse/event_spec.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/models/abuse/event_spec.rb b/spec/models/abuse/event_spec.rb
new file mode 100644
index 00000000000..02527bf80bf
--- /dev/null
+++ b/spec/models/abuse/event_spec.rb
@@ -0,0 +1,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