summaryrefslogtreecommitdiff
path: root/spec/models/ci
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-01 00:09:48 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-01 00:09:48 +0000
commit516b939c44ec77bb773f08df15079c80fb4d10d2 (patch)
tree7fa7670a0cd811df23d8a6b07e6473fa540ebe0f /spec/models/ci
parent9877050db1dd1693c672a6b29a356c5b2a7edce0 (diff)
downloadgitlab-ce-516b939c44ec77bb773f08df15079c80fb4d10d2.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/ci')
-rw-r--r--spec/models/ci/runner_spec.rb40
-rw-r--r--spec/models/ci/runner_version_spec.rb26
2 files changed, 66 insertions, 0 deletions
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb
index b1f5cca647b..63f2731e4d1 100644
--- a/spec/models/ci/runner_spec.rb
+++ b/spec/models/ci/runner_spec.rb
@@ -35,6 +35,46 @@ RSpec.describe Ci::Runner do
end
end
+ describe 'acts_as_taggable' do
+ let(:tag_name) { 'tag123' }
+
+ context 'on save' do
+ let_it_be_with_reload(:runner) { create(:ci_runner) }
+
+ before do
+ runner.tag_list = [tag_name]
+ end
+
+ context 'tag does not exist' do
+ it 'creates a tag' do
+ expect { runner.save! }.to change(ActsAsTaggableOn::Tag, :count).by(1)
+ end
+
+ it 'creates an association to the tag' do
+ runner.save!
+
+ expect(described_class.tagged_with(tag_name)).to include(runner)
+ end
+ end
+
+ context 'tag already exists' do
+ before do
+ ActsAsTaggableOn::Tag.create!(name: tag_name)
+ end
+
+ it 'does not create a tag' do
+ expect { runner.save! }.not_to change(ActsAsTaggableOn::Tag, :count)
+ end
+
+ it 'creates an association to the tag' do
+ runner.save!
+
+ expect(described_class.tagged_with(tag_name)).to include(runner)
+ end
+ end
+ end
+ end
+
describe 'validation' do
it { is_expected.to validate_presence_of(:access_level) }
it { is_expected.to validate_presence_of(:runner_type) }
diff --git a/spec/models/ci/runner_version_spec.rb b/spec/models/ci/runner_version_spec.rb
new file mode 100644
index 00000000000..0303e0bb657
--- /dev/null
+++ b/spec/models/ci/runner_version_spec.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Ci::RunnerVersion do
+ it_behaves_like 'having unique enum values'
+
+ describe '.not_available' do
+ subject { described_class.not_available }
+
+ let!(:runner_version1) { create(:ci_runner_version, version: 'abc123', status: :not_available) }
+ let!(:runner_version2) { create(:ci_runner_version, version: 'abc234', status: :recommended) }
+
+ it { is_expected.to match_array([runner_version1]) }
+ end
+
+ describe 'validation' do
+ context 'when runner version is too long' do
+ let(:runner_version) { build(:ci_runner_version, version: 'a' * 2049) }
+
+ it 'is not valid' do
+ expect(runner_version).to be_invalid
+ end
+ end
+ end
+end