diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-07 15:11:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-07 15:11:20 +0300 |
commit | 8e81ce50767bd5c785072c2487ffb61fe075977c (patch) | |
tree | 87fe3686b23f2581843a068d0278ee4018931c3f /spec/migrations | |
parent | 0125f11d6bf7af5817dce9d87a116e2ed6bd1917 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/20231201171229_detect_and_fix_duplicate_organizations_path_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/migrations/20231201171229_detect_and_fix_duplicate_organizations_path_spec.rb b/spec/migrations/20231201171229_detect_and_fix_duplicate_organizations_path_spec.rb new file mode 100644 index 00000000000..259327bec86 --- /dev/null +++ b/spec/migrations/20231201171229_detect_and_fix_duplicate_organizations_path_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration! + +RSpec.describe DetectAndFixDuplicateOrganizationsPath, feature_category: :cell do + let!(:default_organization) { table(:organizations).create!(name: 'Default', path: 'Default') } + + let(:duplicate_path_name) { 'some_path' } + let!(:organization) { table(:organizations).create!(name: '_name_', path: duplicate_path_name) } + let!(:organization_duplicate) { table(:organizations).create!(name: '_name_', path: duplicate_path_name.upcase) } + let!(:organization_multiple_duplicate) do + table(:organizations).create!(name: '_name_', path: duplicate_path_name.upcase_first) + end + + describe '#up' do + it 'removes the duplication', :aggregate_failures do + expect(organization.path).to eq(duplicate_path_name) + expect(organization_duplicate.path).to eq(duplicate_path_name.upcase) + expect(organization_multiple_duplicate.path).to eq(duplicate_path_name.upcase_first) + expect(default_organization.path).to eq('Default') + + migrate! + + expect(organization.reload.path).to eq(duplicate_path_name) + expect(organization_duplicate.reload.path).to eq("#{duplicate_path_name.upcase}1") + expect(organization_multiple_duplicate.reload.path).to eq("#{duplicate_path_name.upcase_first}2") + expect(default_organization.reload.path).to eq('Default') + end + end +end |