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-08-16 21:09:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-08-16 21:09:33 +0300
commit7e4746d6b8049ac170de633022a662e405ccc818 (patch)
tree33fa57879f1304506a86a4408c2015b05d21bd5c /spec/models
parentab04c244dc7a2405a55d532e1793256a47685f38 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/ci/catalog/resource_spec.rb1
-rw-r--r--spec/models/ci/catalog/resources/component_spec.rb46
-rw-r--r--spec/models/ci/catalog/resources/version_spec.rb1
-rw-r--r--spec/models/project_spec.rb1
4 files changed, 49 insertions, 0 deletions
diff --git a/spec/models/ci/catalog/resource_spec.rb b/spec/models/ci/catalog/resource_spec.rb
index 7af3369ae7b..4608e611ea1 100644
--- a/spec/models/ci/catalog/resource_spec.rb
+++ b/spec/models/ci/catalog/resource_spec.rb
@@ -15,6 +15,7 @@ RSpec.describe Ci::Catalog::Resource, feature_category: :pipeline_composition do
let_it_be(:release3) { create(:release, project: project, released_at: Time.zone.now) }
it { is_expected.to belong_to(:project) }
+ it { is_expected.to have_many(:components).class_name('Ci::Catalog::Resources::Component') }
it { is_expected.to have_many(:versions).class_name('Ci::Catalog::Resources::Version') }
it { is_expected.to delegate_method(:avatar_path).to(:project) }
diff --git a/spec/models/ci/catalog/resources/component_spec.rb b/spec/models/ci/catalog/resources/component_spec.rb
new file mode 100644
index 00000000000..caaf76e610d
--- /dev/null
+++ b/spec/models/ci/catalog/resources/component_spec.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Ci::Catalog::Resources::Component, type: :model, feature_category: :pipeline_composition do
+ let(:component) { build(:catalog_resource_component) }
+
+ it { is_expected.to belong_to(:catalog_resource).class_name('Ci::Catalog::Resource') }
+ it { is_expected.to belong_to(:project) }
+ it { is_expected.to belong_to(:version).class_name('Ci::Catalog::Resources::Version') }
+
+ describe 'validations' do
+ it { is_expected.to validate_presence_of(:catalog_resource) }
+ it { is_expected.to validate_presence_of(:project) }
+ it { is_expected.to validate_presence_of(:version) }
+ it { is_expected.to validate_presence_of(:name) }
+
+ context 'when attributes are valid' do
+ it 'returns no errors' do
+ component.inputs = {
+ website: nil,
+ environment: {
+ default: 'test'
+ },
+ tags: {
+ type: 'array'
+ }
+ }
+ expect(component).to be_valid
+ end
+ end
+
+ context 'when data is invalid' do
+ it 'returns errors' do
+ component.inputs = { boo: [] }
+
+ aggregate_failures do
+ expect(component).to be_invalid
+ expect(component.errors.full_messages).to contain_exactly(
+ 'Inputs must be a valid json schema'
+ )
+ end
+ end
+ end
+ end
+end
diff --git a/spec/models/ci/catalog/resources/version_spec.rb b/spec/models/ci/catalog/resources/version_spec.rb
index f6abb112820..e93176e466a 100644
--- a/spec/models/ci/catalog/resources/version_spec.rb
+++ b/spec/models/ci/catalog/resources/version_spec.rb
@@ -6,6 +6,7 @@ RSpec.describe Ci::Catalog::Resources::Version, type: :model, feature_category:
it { is_expected.to belong_to(:release) }
it { is_expected.to belong_to(:catalog_resource).class_name('Ci::Catalog::Resource') }
it { is_expected.to belong_to(:project) }
+ it { is_expected.to have_many(:components).class_name('Ci::Catalog::Resources::Component') }
describe 'validations' do
it { is_expected.to validate_presence_of(:release) }
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index a9b704608ef..5d622b8eccd 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -46,6 +46,7 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr
it { is_expected.to have_one(:design_management_repository).class_name('DesignManagement::Repository').inverse_of(:project) }
it { is_expected.to have_one(:slack_integration) }
it { is_expected.to have_one(:catalog_resource) }
+ it { is_expected.to have_many(:ci_components).class_name('Ci::Catalog::Resources::Component') }
it { is_expected.to have_many(:catalog_resource_versions).class_name('Ci::Catalog::Resources::Version') }
it { is_expected.to have_one(:microsoft_teams_integration) }
it { is_expected.to have_one(:mattermost_integration) }