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:
Diffstat (limited to 'spec/migrations/rename_sitemap_namespace_spec.rb')
-rw-r--r--spec/migrations/rename_sitemap_namespace_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/migrations/rename_sitemap_namespace_spec.rb b/spec/migrations/rename_sitemap_namespace_spec.rb
new file mode 100644
index 00000000000..83f0721c600
--- /dev/null
+++ b/spec/migrations/rename_sitemap_namespace_spec.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20201102112206_rename_sitemap_namespace.rb')
+
+RSpec.describe RenameSitemapNamespace do
+ let(:namespaces) { table(:namespaces) }
+ let(:routes) { table(:routes) }
+ let(:sitemap_path) { 'sitemap' }
+
+ it 'correctly run #up and #down' do
+ create_namespace(sitemap_path)
+
+ reversible_migration do |migration|
+ migration.before -> {
+ expect(namespaces.pluck(:path)).to contain_exactly(sitemap_path)
+ }
+
+ migration.after -> {
+ expect(namespaces.pluck(:path)).to contain_exactly(sitemap_path + '0')
+ }
+ end
+ end
+
+ def create_namespace(path)
+ namespaces.create!(name: path, path: path).tap do |namespace|
+ routes.create!(path: namespace.path, name: namespace.name, source_id: namespace.id, source_type: 'Namespace')
+ end
+ end
+end