summaryrefslogtreecommitdiff
path: root/spec/models/analytics
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-14 18:10:34 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-14 18:10:34 +0000
commit7d4b2ed7bf75d316577b718c71a9fdef19184539 (patch)
treed709e00c4f2ab60901749883f324f9069343037c /spec/models/analytics
parent7172fb10313a9a7790f8e033b347e77df4987154 (diff)
downloadgitlab-ce-7d4b2ed7bf75d316577b718c71a9fdef19184539.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/analytics')
-rw-r--r--spec/models/analytics/cycle_analytics/project_stage_spec.rb1
-rw-r--r--spec/models/analytics/cycle_analytics/project_value_stream_spec.rb39
2 files changed, 40 insertions, 0 deletions
diff --git a/spec/models/analytics/cycle_analytics/project_stage_spec.rb b/spec/models/analytics/cycle_analytics/project_stage_spec.rb
index fce31af619c..9efe90e7d41 100644
--- a/spec/models/analytics/cycle_analytics/project_stage_spec.rb
+++ b/spec/models/analytics/cycle_analytics/project_stage_spec.rb
@@ -17,6 +17,7 @@ RSpec.describe Analytics::CycleAnalytics::ProjectStage do
end
it_behaves_like 'value stream analytics stage' do
+ let(:factory) { :cycle_analytics_project_stage }
let(:parent) { build(:project) }
let(:parent_name) { :project }
end
diff --git a/spec/models/analytics/cycle_analytics/project_value_stream_spec.rb b/spec/models/analytics/cycle_analytics/project_value_stream_spec.rb
new file mode 100644
index 00000000000..d84ecedc634
--- /dev/null
+++ b/spec/models/analytics/cycle_analytics/project_value_stream_spec.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Analytics::CycleAnalytics::ProjectValueStream, type: :model do
+ describe 'associations' do
+ it { is_expected.to belong_to(:project) }
+ it { is_expected.to have_many(:stages) }
+ end
+
+ describe 'validations' do
+ it { is_expected.to validate_presence_of(:project) }
+ it { is_expected.to validate_presence_of(:name) }
+ it { is_expected.to validate_length_of(:name).is_at_most(100) }
+
+ it 'validates uniqueness of name' do
+ project = create(:project)
+ create(:cycle_analytics_project_value_stream, name: 'test', project: project)
+
+ value_stream = build(:cycle_analytics_project_value_stream, name: 'test', project: project)
+
+ expect(value_stream).to be_invalid
+ expect(value_stream.errors.messages).to eq(name: [I18n.t('errors.messages.taken')])
+ end
+ end
+
+ it 'is not custom' do
+ expect(described_class.new).not_to be_custom
+ end
+
+ describe '.build_default_value_stream' do
+ it 'builds the default value stream' do
+ project = build(:project)
+
+ value_stream = described_class.build_default_value_stream(project)
+ expect(value_stream.name).to eq('default')
+ end
+ end
+end