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')
-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
5 files changed, 112 insertions, 8 deletions
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 }