Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-02 06:08:01 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-02 06:08:01 +0300
commit796b00a98a82fcbe082c9343fd4efcccc77478dc (patch)
tree257bcb124f57cb91a8dff75e69649e8a2f91c51d /spec/migrations
parent93dcf45d441bc884b167f4338380c8c888e9b86f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/20200313203550_remove_orphaned_chat_names_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/migrations/20200313203550_remove_orphaned_chat_names_spec.rb b/spec/migrations/20200313203550_remove_orphaned_chat_names_spec.rb
new file mode 100644
index 00000000000..fd30ebaa66f
--- /dev/null
+++ b/spec/migrations/20200313203550_remove_orphaned_chat_names_spec.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20200313203550_remove_orphaned_chat_names.rb')
+
+describe RemoveOrphanedChatNames, schema: 20200313202430 do
+ let(:projects) { table(:projects) }
+ let(:namespaces) { table(:namespaces) }
+ let(:services) { table(:services) }
+ let(:chat_names) { table(:chat_names) }
+
+ let(:namespace) { namespaces.create(name: 'foo', path: 'foo') }
+ let(:project) { projects.create(namespace_id: namespace.id) }
+ let(:service) { services.create(project_id: project.id, type: 'chat') }
+ let(:chat_name) { chat_names.create!(service_id: service.id, team_id: 'TEAM', user_id: 12345, chat_id: 12345) }
+ let(:orphaned_chat_name) { chat_names.create!(team_id: 'TEAM', service_id: 0, user_id: 12345, chat_id: 12345) }
+
+ it 'removes the orphaned chat_name' do
+ expect(chat_name).to be_present
+ expect(orphaned_chat_name).to be_present
+
+ migrate!
+
+ expect(chat_names.where(id: orphaned_chat_name.id)).to be_empty
+ expect(chat_name.reload).to be_present
+ end
+end