diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2018-08-25 05:38:54 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-08-25 05:38:54 +0000 |
commit | 08cc6afc6eaa05fbc072452901a7d381bbdb2af8 (patch) | |
tree | c6e4f3779ff9ff13e3539681a7ac34488aaa8d16 /spec/migrations/drop_duplicate_protected_tags_spec.rb | |
parent | 26ea5437f17ce2a6546fbfd644b93b7f18896783 (diff) | |
download | gitlab-ce-08cc6afc6eaa05fbc072452901a7d381bbdb2af8.tar.gz |
API: Protected tags
Diffstat (limited to 'spec/migrations/drop_duplicate_protected_tags_spec.rb')
-rw-r--r-- | spec/migrations/drop_duplicate_protected_tags_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/migrations/drop_duplicate_protected_tags_spec.rb b/spec/migrations/drop_duplicate_protected_tags_spec.rb new file mode 100644 index 00000000000..acfb6850722 --- /dev/null +++ b/spec/migrations/drop_duplicate_protected_tags_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' +require Rails.root.join('db', 'migrate', '20180711103851_drop_duplicate_protected_tags.rb') + +describe DropDuplicateProtectedTags, :migration do + let(:namespaces) { table(:namespaces) } + let(:projects) { table(:projects) } + let(:protected_tags) { table(:protected_tags) } + + before do + stub_const("#{described_class}::BATCH_SIZE", 2) + + namespaces.create(id: 1, name: 'gitlab-org', path: 'gitlab-org') + projects.create!(id: 1, namespace_id: 1, name: 'gitlab1', path: 'gitlab1') + projects.create!(id: 2, namespace_id: 1, name: 'gitlab2', path: 'gitlab2') + end + + it 'removes duplicated protected tags' do + protected_tags.create!(id: 1, project_id: 1, name: 'foo') + tag2 = protected_tags.create!(id: 2, project_id: 1, name: 'foo1') + protected_tags.create!(id: 3, project_id: 1, name: 'foo') + tag4 = protected_tags.create!(id: 4, project_id: 1, name: 'foo') + tag5 = protected_tags.create!(id: 5, project_id: 2, name: 'foo') + + migrate! + + expect(protected_tags.all.count).to eq 3 + expect(protected_tags.all.pluck(:id)).to contain_exactly(tag2.id, tag4.id, tag5.id) + end + + it 'does not remove unique protected tags' do + tag1 = protected_tags.create!(id: 1, project_id: 1, name: 'foo1') + tag2 = protected_tags.create!(id: 2, project_id: 1, name: 'foo2') + tag3 = protected_tags.create!(id: 3, project_id: 1, name: 'foo3') + + migrate! + + expect(protected_tags.all.count).to eq 3 + expect(protected_tags.all.pluck(:id)).to contain_exactly(tag1.id, tag2.id, tag3.id) + end +end |