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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2024-01-08 12:12:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-08 12:12:05 +0300
commitd59bc6c73d927d63d04f86f8b1d2e471787d48d1 (patch)
tree205daf86ac4049e30479a521a24f3242ff326a7a /spec
parent80abbcbeaf4b0c47a8fe6201bd5e2d9c8af6e272 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/integrations.rb8
-rw-r--r--spec/lib/gitlab/import_export/all_models.yml7
-rw-r--r--spec/lib/gitlab/import_export/safe_model_attributes.yml7
-rw-r--r--spec/migrations/20230228142350_add_notifications_work_item_widget_spec.rb4
-rw-r--r--spec/migrations/20230317162059_add_current_user_todos_work_item_widget_spec.rb4
-rw-r--r--spec/migrations/20230323101138_add_award_emoji_work_item_widget_spec.rb4
-rw-r--r--spec/migrations/20230807083334_add_linked_items_work_item_widget_spec.rb4
-rw-r--r--spec/migrations/20231211154654_add_work_items_rolledup_dates_widget_spec.rb3
-rw-r--r--spec/models/ci/build_spec.rb28
-rw-r--r--spec/models/concerns/routable_spec.rb14
-rw-r--r--spec/models/integrations/diffblue_cover_spec.rb74
-rw-r--r--spec/models/time_tracking/timelog_category_spec.rb3
-rw-r--r--spec/models/timelog_spec.rb1
-rw-r--r--spec/support/shared_examples/migrations/add_work_item_widget_shared_examples.rb6
14 files changed, 151 insertions, 16 deletions
diff --git a/spec/factories/integrations.rb b/spec/factories/integrations.rb
index 74dfea585f2..1d698e1b4d8 100644
--- a/spec/factories/integrations.rb
+++ b/spec/factories/integrations.rb
@@ -30,6 +30,14 @@ FactoryBot.define do
api_key { 'secret' }
end
+ factory :diffblue_cover_integration, class: 'Integrations::DiffblueCover' do
+ project
+ active { true }
+ diffblue_license_key { '1234-ABCD-DCBA-4321' }
+ diffblue_access_token_name { 'Diffblue CI' }
+ diffblue_access_token_secret { 'glpat-00112233445566778899' } # gitleaks:allow
+ end
+
factory :emails_on_push_integration, class: 'Integrations::EmailsOnPush' do
project
type { 'Integrations::EmailsOnPush' }
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml
index 688487df778..5d666ccb15a 100644
--- a/spec/lib/gitlab/import_export/all_models.yml
+++ b/spec/lib/gitlab/import_export/all_models.yml
@@ -588,6 +588,7 @@ project:
- hangouts_chat_integration
- unify_circuit_integration
- buildkite_integration
+- diffblue_cover_integration
- bamboo_integration
- teamcity_integration
- pushover_integration
@@ -848,6 +849,7 @@ timelogs:
- merge_request
- user
- note
+- timelog_category
push_event_payload:
- event
issue_assignees:
@@ -1081,3 +1083,8 @@ approval_project_rules_users:
approval_project_rules_protected_branches:
- protected_branch
- approval_project_rule
+timelog_category:
+ - name
+ - description
+ - billable
+ - billing_rate
diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml
index 3efa33d8879..73b945d4274 100644
--- a/spec/lib/gitlab/import_export/safe_model_attributes.yml
+++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml
@@ -765,6 +765,7 @@ Timelog:
- created_at
- updated_at
- summary
+- timelog_category_id
ProjectAutoDevops:
- id
- enabled
@@ -1087,3 +1088,9 @@ ApprovalProjectRulesProtectedBranch:
- branch_name
WorkItems::Type:
- base_type
+TimeTracking::TimelogCategories:
+ - id
+ - name
+ - description
+ - billable
+ - billing_rate
diff --git a/spec/migrations/20230228142350_add_notifications_work_item_widget_spec.rb b/spec/migrations/20230228142350_add_notifications_work_item_widget_spec.rb
index 7161ca35edd..a459ef96737 100644
--- a/spec/migrations/20230228142350_add_notifications_work_item_widget_spec.rb
+++ b/spec/migrations/20230228142350_add_notifications_work_item_widget_spec.rb
@@ -4,5 +4,7 @@ require 'spec_helper'
require_migration!
RSpec.describe AddNotificationsWorkItemWidget, :migration, feature_category: :team_planning do
- it_behaves_like 'migration that adds widget to work items definitions', widget_name: 'Notifications'
+ it_behaves_like 'migration that adds widget to work items definitions',
+ widget_name: described_class::WIDGET_NAME,
+ work_item_types: described_class::WORK_ITEM_TYPES
end
diff --git a/spec/migrations/20230317162059_add_current_user_todos_work_item_widget_spec.rb b/spec/migrations/20230317162059_add_current_user_todos_work_item_widget_spec.rb
index 1df80a519f2..c202638aa27 100644
--- a/spec/migrations/20230317162059_add_current_user_todos_work_item_widget_spec.rb
+++ b/spec/migrations/20230317162059_add_current_user_todos_work_item_widget_spec.rb
@@ -4,5 +4,7 @@ require 'spec_helper'
require_migration!
RSpec.describe AddCurrentUserTodosWorkItemWidget, :migration, feature_category: :team_planning do
- it_behaves_like 'migration that adds widget to work items definitions', widget_name: 'Current user todos'
+ it_behaves_like 'migration that adds widget to work items definitions',
+ widget_name: described_class::WIDGET_NAME,
+ work_item_types: described_class::WORK_ITEM_TYPES
end
diff --git a/spec/migrations/20230323101138_add_award_emoji_work_item_widget_spec.rb b/spec/migrations/20230323101138_add_award_emoji_work_item_widget_spec.rb
index 16a205c5da5..7987f0257ee 100644
--- a/spec/migrations/20230323101138_add_award_emoji_work_item_widget_spec.rb
+++ b/spec/migrations/20230323101138_add_award_emoji_work_item_widget_spec.rb
@@ -4,5 +4,7 @@ require 'spec_helper'
require_migration!
RSpec.describe AddAwardEmojiWorkItemWidget, :migration, feature_category: :team_planning do
- it_behaves_like 'migration that adds widget to work items definitions', widget_name: 'Award emoji'
+ it_behaves_like 'migration that adds widget to work items definitions',
+ widget_name: described_class::WIDGET_NAME,
+ work_item_types: described_class::WORK_ITEM_TYPES
end
diff --git a/spec/migrations/20230807083334_add_linked_items_work_item_widget_spec.rb b/spec/migrations/20230807083334_add_linked_items_work_item_widget_spec.rb
index 7b759182a21..eae4910eef3 100644
--- a/spec/migrations/20230807083334_add_linked_items_work_item_widget_spec.rb
+++ b/spec/migrations/20230807083334_add_linked_items_work_item_widget_spec.rb
@@ -4,5 +4,7 @@ require 'spec_helper'
require_migration!
RSpec.describe AddLinkedItemsWorkItemWidget, :migration, feature_category: :portfolio_management do
- it_behaves_like 'migration that adds widget to work items definitions', widget_name: 'Linked items'
+ it_behaves_like 'migration that adds widget to work items definitions',
+ widget_name: described_class::WIDGET_NAME,
+ work_item_types: described_class::WORK_ITEM_TYPES
end
diff --git a/spec/migrations/20231211154654_add_work_items_rolledup_dates_widget_spec.rb b/spec/migrations/20231211154654_add_work_items_rolledup_dates_widget_spec.rb
index 2c3d20dcc56..b7bae52eed5 100644
--- a/spec/migrations/20231211154654_add_work_items_rolledup_dates_widget_spec.rb
+++ b/spec/migrations/20231211154654_add_work_items_rolledup_dates_widget_spec.rb
@@ -5,5 +5,6 @@ require_migration!
RSpec.describe AddWorkItemsRolledupDatesWidget, :migration, feature_category: :team_planning do
it_behaves_like 'migration that adds widget to work items definitions',
- widget_name: 'Rolledup dates'
+ widget_name: described_class::WIDGET_NAME,
+ work_item_types: described_class::WORK_ITEM_TYPES
end
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index c5c97228988..121cb5e8dda 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -3290,6 +3290,34 @@ RSpec.describe Ci::Build, feature_category: :continuous_integration, factory_def
end
end
+ context 'for the diffblue_cover integration' do
+ context 'when active' do
+ let_it_be(:diffblue_cover_integration) { create(:diffblue_cover_integration, active: true) }
+
+ let(:diffblue_cover_variables) do
+ [
+ { key: 'DIFFBLUE_LICENSE_KEY', value: diffblue_cover_integration.diffblue_license_key, masked: true, public: false },
+ { key: 'DIFFBLUE_ACCESS_TOKEN_NAME', value: diffblue_cover_integration.diffblue_access_token_name, masked: true, public: false },
+ { key: 'DIFFBLUE_ACCESS_TOKEN', value: diffblue_cover_integration.diffblue_access_token_secret, masked: true, public: false }
+ ]
+ end
+
+ it 'includes diffblue_cover variables' do
+ is_expected.to include(*diffblue_cover_variables)
+ end
+ end
+
+ context 'when inactive' do
+ let_it_be(:diffblue_cover_integration) { create(:diffblue_cover_integration, active: false) }
+
+ it 'does not include diffblue_cover variables' do
+ expect(subject.find { |v| v[:key] == 'DIFFBLUE_LICENSE_KEY' }).to be_nil
+ expect(subject.find { |v| v[:key] == 'DIFFBLUE_ACCESS_TOKEN_NAME' }).to be_nil
+ expect(subject.find { |v| v[:key] == 'DIFFBLUE_ACCESS_TOKEN' }).to be_nil
+ end
+ end
+ end
+
context 'for the google_play integration' do
before do
allow(build.pipeline).to receive(:protected_ref?).and_return(pipeline_protected_ref)
diff --git a/spec/models/concerns/routable_spec.rb b/spec/models/concerns/routable_spec.rb
index 84bff839d1b..a9149b0eebe 100644
--- a/spec/models/concerns/routable_spec.rb
+++ b/spec/models/concerns/routable_spec.rb
@@ -82,15 +82,15 @@ RSpec.shared_examples 'routable resource' do
end
end
- context 'on the usage of `use_includes` parameter' do
+ context 'on the usage of `preload_routes` parameter' do
let_it_be(:klass) { record.class.to_s.downcase }
let_it_be(:record_3) { create(:"#{klass}") }
let_it_be(:record_4) { create(:"#{klass}") }
- context 'when use_includes: true' do
+ context 'when preload_routes: true' do
it 'includes route information when loading records' do
control = ActiveRecord::QueryRecorder.new do
- described_class.where_full_path_in([record.full_path, record_2.full_path], use_includes: true)
+ described_class.where_full_path_in([record.full_path, record_2.full_path], preload_routes: true)
.map(&:route)
end
@@ -101,16 +101,16 @@ RSpec.shared_examples 'routable resource' do
record_2.full_path,
record_3.full_path,
record_4.full_path
- ], use_includes: true)
+ ], preload_routes: true)
.map(&:route)
end.to issue_same_number_of_queries_as(control)
end
end
- context 'when use_includes: false' do
+ context 'when preload_routes: false' do
it 'does not include route information when loading records' do
control_count = ActiveRecord::QueryRecorder.new do
- described_class.where_full_path_in([record.full_path, record_2.full_path], use_includes: false)
+ described_class.where_full_path_in([record.full_path, record_2.full_path], preload_routes: false)
.map(&:route)
end
@@ -121,7 +121,7 @@ RSpec.shared_examples 'routable resource' do
record_2.full_path,
record_3.full_path,
record_4.full_path
- ], use_includes: false)
+ ], preload_routes: false)
.map(&:route)
end.not_to issue_same_number_of_queries_as(control_count)
end
diff --git a/spec/models/integrations/diffblue_cover_spec.rb b/spec/models/integrations/diffblue_cover_spec.rb
new file mode 100644
index 00000000000..c1a98cc2fbd
--- /dev/null
+++ b/spec/models/integrations/diffblue_cover_spec.rb
@@ -0,0 +1,74 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Integrations::DiffblueCover, feature_category: :integrations do
+ let_it_be(:project) { build(:project) }
+
+ subject(:integration) { build(:diffblue_cover_integration, project: project) }
+
+ describe 'Validations' do
+ context 'when active' do
+ before do
+ integration.active = true
+ end
+
+ it { is_expected.to validate_presence_of(:diffblue_license_key) }
+ it { is_expected.to validate_presence_of(:diffblue_access_token_name) }
+ it { is_expected.to validate_presence_of(:diffblue_access_token_secret) }
+ end
+
+ context 'when inactive' do
+ before do
+ integration.active = false
+ end
+
+ it { is_expected.not_to validate_presence_of(:diffblue_license_key) }
+ it { is_expected.not_to validate_presence_of(:diffblue_access_token_name) }
+ it { is_expected.not_to validate_presence_of(:diffblue_access_token_secret) }
+ end
+ end
+
+ describe '#avatar_url' do
+ it 'returns the avatar image path' do
+ expect(integration.avatar_url).to eq(ActionController::Base.helpers.image_path(
+ 'illustrations/third-party-logos/integrations-logos/diffblue.svg'
+ ))
+ end
+ end
+
+ describe '#ci-vars' do
+ let(:ci_vars) do
+ [
+ { key: 'DIFFBLUE_LICENSE_KEY', value: '1234-ABCD-DCBA-4321', public: false, masked: true },
+ { key: 'DIFFBLUE_ACCESS_TOKEN_NAME', value: 'Diffblue CI', public: false, masked: true },
+ { key: 'DIFFBLUE_ACCESS_TOKEN',
+ value: 'glpat-00112233445566778899', public: false, masked: true } # gitleaks:allow
+ ]
+ end
+
+ context 'when active' do
+ before do
+ integration.active = true
+ end
+
+ it 'returns the required pipeline vars' do
+ expect(integration.ci_variables).to match_array(ci_vars)
+ end
+ end
+
+ context 'when inactive' do
+ before do
+ integration.active = false
+ end
+
+ it 'does not return the required pipeline vars' do
+ expect(integration.ci_variables).to be_empty
+ end
+ end
+ end
+
+ describe '#diffblue_link' do
+ it { expect(described_class.diffblue_link).to include("https://www.diffblue.com/try-cover/gitlab/") }
+ end
+end
diff --git a/spec/models/time_tracking/timelog_category_spec.rb b/spec/models/time_tracking/timelog_category_spec.rb
index ac2fb651134..d07ba29091c 100644
--- a/spec/models/time_tracking/timelog_category_spec.rb
+++ b/spec/models/time_tracking/timelog_category_spec.rb
@@ -2,9 +2,10 @@
require 'spec_helper'
-RSpec.describe TimeTracking::TimelogCategory, type: :model do
+RSpec.describe TimeTracking::TimelogCategory, feature_category: :team_planning do
describe 'associations' do
it { is_expected.to belong_to(:namespace).with_foreign_key('namespace_id') }
+ it { is_expected.to have_many(:timelogs) }
end
describe 'default values' do
diff --git a/spec/models/timelog_spec.rb b/spec/models/timelog_spec.rb
index aee2c4ded19..dc87aea0cb4 100644
--- a/spec/models/timelog_spec.rb
+++ b/spec/models/timelog_spec.rb
@@ -11,6 +11,7 @@ RSpec.describe Timelog, feature_category: :team_planning do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:issue).touch(true) }
it { is_expected.to belong_to(:merge_request).touch(true) }
+ it { is_expected.to belong_to(:timelog_category).optional(true) }
it { is_expected.to be_valid }
diff --git a/spec/support/shared_examples/migrations/add_work_item_widget_shared_examples.rb b/spec/support/shared_examples/migrations/add_work_item_widget_shared_examples.rb
index aa5c7ffe7be..5681dbc158d 100644
--- a/spec/support/shared_examples/migrations/add_work_item_widget_shared_examples.rb
+++ b/spec/support/shared_examples/migrations/add_work_item_widget_shared_examples.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-RSpec.shared_examples 'migration that adds widget to work items definitions' do |widget_name:|
+RSpec.shared_examples 'migration that adds widget to work items definitions' do |widget_name:, work_item_types:|
let(:migration) { described_class.new }
let(:work_item_definitions) { table(:work_item_widget_definitions) }
- let(:work_item_type_count) { described_class::WORK_ITEM_TYPES.size }
+ let(:work_item_type_count) { work_item_types.size }
describe '#up' do
it "creates widget definition in all types" do
@@ -14,7 +14,7 @@ RSpec.shared_examples 'migration that adds widget to work items definitions' do
end
it 'logs a warning if the type is missing' do
- type_name = described_class::WORK_ITEM_TYPES.first
+ type_name = work_item_types.first
allow(described_class::WorkItemType).to receive(:find_by_name_and_namespace_id).and_call_original
allow(described_class::WorkItemType).to receive(:find_by_name_and_namespace_id)