diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/migrations/add_default_value_stream_to_groups_with_group_stages_spec.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/migrations/add_default_value_stream_to_groups_with_group_stages_spec.rb')
-rw-r--r-- | spec/migrations/add_default_value_stream_to_groups_with_group_stages_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/migrations/add_default_value_stream_to_groups_with_group_stages_spec.rb b/spec/migrations/add_default_value_stream_to_groups_with_group_stages_spec.rb new file mode 100644 index 00000000000..31dee29a39b --- /dev/null +++ b/spec/migrations/add_default_value_stream_to_groups_with_group_stages_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20200701070435_add_default_value_stream_to_groups_with_group_stages.rb') + +RSpec.describe AddDefaultValueStreamToGroupsWithGroupStages, schema: 20200624142207 do + let(:groups) { table(:namespaces) } + let(:group_stages) { table(:analytics_cycle_analytics_group_stages) } + let(:value_streams) { table(:analytics_cycle_analytics_group_value_streams) } + + let!(:group) { groups.create!(name: 'test', path: 'path', type: 'Group') } + let!(:group_stage) { group_stages.create!(name: 'test', group_id: group.id, start_event_identifier: 1, end_event_identifier: 2) } + + describe '#up' do + it 'creates default value stream record for the group' do + migrate! + + group_value_streams = value_streams.where(group_id: group.id) + expect(group_value_streams.size).to eq(1) + + value_stream = group_value_streams.first + expect(value_stream.name).to eq('default') + end + + it 'migrates existing stages to the default value stream' do + migrate! + + group_stage.reload + + value_stream = value_streams.find_by(group_id: group.id, name: 'default') + expect(group_stage.group_value_stream_id).to eq(value_stream.id) + end + end + + describe '#down' do + it 'sets the group_value_stream_id to nil' do + described_class.new.down + + group_stage.reload + + expect(group_stage.group_value_stream_id).to be_nil + end + end +end |