summaryrefslogtreecommitdiff
path: root/spec/models/concerns
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-04-12 18:15:19 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2017-04-12 18:15:19 +0200
commit223d8a3d26a7561fcae9536efbf120d7c4760bd4 (patch)
treee87582544e973da9ddb6fba97b2958bbc0508751 /spec/models/concerns
parenta179c5ca412ebf1fbe7432c654f4bea6d155233b (diff)
downloadgitlab-ce-223d8a3d26a7561fcae9536efbf120d7c4760bd4.tar.gz
Prepare for zero downtime migrationszero-downtime-migrations
Starting with GitLab 9.1.0 we will no longer allow downtime migrations unless absolutely necessary. This commit updates the various developer guides and adds code that is necessary to make zero downtime migrations less painful.
Diffstat (limited to 'spec/models/concerns')
-rw-r--r--spec/models/concerns/ignorable_column_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/models/concerns/ignorable_column_spec.rb b/spec/models/concerns/ignorable_column_spec.rb
new file mode 100644
index 00000000000..dba9fe43327
--- /dev/null
+++ b/spec/models/concerns/ignorable_column_spec.rb
@@ -0,0 +1,38 @@
+require 'spec_helper'
+
+describe IgnorableColumn do
+ let :base_class do
+ Class.new do
+ def self.columns
+ # This method does not have access to "double"
+ [Struct.new(:name).new('id'), Struct.new(:name).new('title')]
+ end
+ end
+ end
+
+ let :model do
+ Class.new(base_class) do
+ include IgnorableColumn
+ end
+ end
+
+ describe '.columns' do
+ it 'returns the columns, excluding the ignored ones' do
+ model.ignore_column(:title)
+
+ expect(model.columns.map(&:name)).to eq(%w(id))
+ end
+ end
+
+ describe '.ignored_columns' do
+ it 'returns a Set' do
+ expect(model.ignored_columns).to be_an_instance_of(Set)
+ end
+
+ it 'returns the names of the ignored columns' do
+ model.ignore_column(:title)
+
+ expect(model.ignored_columns).to eq(Set.new(%w(title)))
+ end
+ end
+end