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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-14 00:09:09 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-14 00:09:09 +0300
commit04cc87ee46c1c0b6b4eb7df964b3115dd2578877 (patch)
tree2c64b0e21804fc0981a2142eb83a0b73d85fbcda /spec/models
parent4a064b8dc0bf350b1b3000698042b49113e758d1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/abuse/event_spec.rb48
-rw-r--r--spec/models/concerns/issuable_spec.rb2
-rw-r--r--spec/models/identity_spec.rb2
-rw-r--r--spec/models/snippet_repository_spec.rb2
-rw-r--r--spec/models/user_spec.rb1
-rw-r--r--spec/models/work_item_spec.rb11
6 files changed, 60 insertions, 6 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
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb
index 42b70cbb858..4e99419a7f2 100644
--- a/spec/models/concerns/issuable_spec.rb
+++ b/spec/models/concerns/issuable_spec.rb
@@ -896,7 +896,7 @@ RSpec.describe Issuable do
let(:first_time_contributor_issue) { create(:issue, author: first_time_contributor, project: project) }
it "is false even without merged MR" do
- expect(merged_mr).to be
+ expect(merged_mr).to be_present
expect(first_time_contributor_issue).not_to be_first_contribution
expect(contributor_issue).not_to be_first_contribution
end
diff --git a/spec/models/identity_spec.rb b/spec/models/identity_spec.rb
index 124c54a2028..0bbf24534fb 100644
--- a/spec/models/identity_spec.rb
+++ b/spec/models/identity_spec.rb
@@ -88,7 +88,7 @@ RSpec.describe Identity do
it 'finds any extern uids associated with a provider' do
identity = described_class.with_any_extern_uid('test_provider').first
- expect(identity).to be
+ expect(identity).to be_present
end
end
diff --git a/spec/models/snippet_repository_spec.rb b/spec/models/snippet_repository_spec.rb
index 050f99fd4d5..c2fbede8ea9 100644
--- a/spec/models/snippet_repository_spec.rb
+++ b/spec/models/snippet_repository_spec.rb
@@ -223,7 +223,7 @@ RSpec.describe SnippetRepository do
snippet_repository.multi_files_action(user, [new_file], **commit_opts)
- expect(blob_at(snippet, default_name)).to be
+ expect(blob_at(snippet, default_name)).to be_present
end
it 'reuses the existing file name' do
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index d4c9df936d6..768198bc826 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -161,6 +161,7 @@ RSpec.describe User, feature_category: :user_profile do
it { is_expected.to have_many(:reported_abuse_reports).dependent(:nullify).class_name('AbuseReport').inverse_of(:reporter) }
it { is_expected.to have_many(:assigned_abuse_reports).class_name('AbuseReport').inverse_of(:assignee) }
it { is_expected.to have_many(:resolved_abuse_reports).class_name('AbuseReport').inverse_of(:resolved_by) }
+ it { is_expected.to have_many(:abuse_events).class_name('Abuse::Event').inverse_of(:user) }
it { is_expected.to have_many(:custom_attributes).class_name('UserCustomAttribute') }
it { is_expected.to have_many(:releases).dependent(:nullify) }
it { is_expected.to have_many(:metrics_users_starred_dashboards).inverse_of(:user) }
diff --git a/spec/models/work_item_spec.rb b/spec/models/work_item_spec.rb
index 5a525d83c3b..e0ec54fd5ff 100644
--- a/spec/models/work_item_spec.rb
+++ b/spec/models/work_item_spec.rb
@@ -132,7 +132,7 @@ RSpec.describe WorkItem, feature_category: :portfolio_management do
subject { work_item.supported_quick_action_commands }
it 'returns quick action commands supported for all work items' do
- is_expected.to include(:title, :reopen, :close, :cc, :tableflip, :shrug, :type)
+ is_expected.to include(:title, :reopen, :close, :cc, :tableflip, :shrug, :type, :promote_to)
end
context 'when work item supports the assignee widget' do
@@ -461,8 +461,13 @@ RSpec.describe WorkItem, feature_category: :portfolio_management do
it 'does not allow to change types' do
expect(child.valid?).to eq(false)
- expect(child.errors[:work_item_type_id])
- .to include("cannot be changed to #{new_type.name} with #{parent.work_item_type.name} as parent type.")
+ expect(child.errors[:work_item_type_id]).to include(
+ format(
+ "cannot be changed to %{type_name} when linked to a parent %{parent_name}.",
+ type_name: new_type.name.downcase,
+ parent_name: parent.work_item_type.name.downcase
+ )
+ )
end
end
end