Commit 286004e7 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch '331410-editing-persisted-value-stream' into 'master'

Allow editing persisted value stream

See merge request gitlab-org/gitlab!62095
parents 91596934 6418b963
...@@ -13,6 +13,6 @@ class Analytics::CycleAnalytics::GroupValueStream < ApplicationRecord ...@@ -13,6 +13,6 @@ class Analytics::CycleAnalytics::GroupValueStream < ApplicationRecord
scope :preload_associated_models, -> { includes(:group, stages: [:group, :end_event_label, :start_event_label]) } scope :preload_associated_models, -> { includes(:group, stages: [:group, :end_event_label, :start_event_label]) }
def custom? def custom?
name != Analytics::CycleAnalytics::Stages::BaseService::DEFAULT_VALUE_STREAM_NAME persisted? || name != Analytics::CycleAnalytics::Stages::BaseService::DEFAULT_VALUE_STREAM_NAME
end end
end end
...@@ -178,17 +178,6 @@ RSpec.describe Groups::Analytics::CycleAnalytics::ValueStreamsController do ...@@ -178,17 +178,6 @@ RSpec.describe Groups::Analytics::CycleAnalytics::ValueStreamsController do
delete :destroy, params: { group_id: group, id: value_stream } delete :destroy, params: { group_id: group, id: value_stream }
end end
context 'when it is a default value stream' do
let!(:value_stream) { create(:cycle_analytics_group_value_stream, group: group, name: 'default') }
it 'returns an unprocessable entity 422 response without deleting the value stream' do
expect { destroy_value_stream }.not_to change { Analytics::CycleAnalytics::GroupValueStream.count }
expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(json_response["message"]).to eq('The Default Value Stream cannot be deleted')
end
end
context 'when it is a custom value stream' do context 'when it is a custom value stream' do
let!(:value_stream) { create(:cycle_analytics_group_value_stream, group: group, name: 'some custom value stream') } let!(:value_stream) { create(:cycle_analytics_group_value_stream, group: group, name: 'some custom value stream') }
let!(:stage) { create(:cycle_analytics_group_stage, value_stream: value_stream) } let!(:stage) { create(:cycle_analytics_group_stage, value_stream: value_stream) }
......
...@@ -3,5 +3,7 @@ ...@@ -3,5 +3,7 @@
FactoryBot.define do FactoryBot.define do
factory :cycle_analytics_group_value_stream, class: 'Analytics::CycleAnalytics::GroupValueStream' do factory :cycle_analytics_group_value_stream, class: 'Analytics::CycleAnalytics::GroupValueStream' do
sequence(:name) { |n| "Value Stream ##{n}" } sequence(:name) { |n| "Value Stream ##{n}" }
group
end end
end end
...@@ -45,4 +45,28 @@ RSpec.describe Analytics::CycleAnalytics::GroupValueStream, type: :model do ...@@ -45,4 +45,28 @@ RSpec.describe Analytics::CycleAnalytics::GroupValueStream, type: :model do
end end
end end
end end
describe '#custom?' do
context 'when value stream is not persisted' do
subject(:value_stream) { build(:cycle_analytics_group_value_stream, name: value_stream_name) }
context 'when the name of the value stream is default' do
let(:value_stream_name) { Analytics::CycleAnalytics::Stages::BaseService::DEFAULT_VALUE_STREAM_NAME }
it { is_expected.not_to be_custom }
end
context 'when the name of the value stream is not default' do
let(:value_stream_name) { 'value_stream_1' }
it { is_expected.to be_custom }
end
end
context 'when value stream is persisted' do
subject(:value_stream) { create(:cycle_analytics_group_value_stream, name: 'value_stream_1') }
it { is_expected.to be_custom }
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment