diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-04-12 23:43:12 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-04-12 23:43:12 +0300 |
commit | 3584f7dd527a7dfac4926410780e999237e861b4 (patch) | |
tree | ad0dc2743bb54d336e67f0d73a7539df7f9a3107 /spec/models | |
parent | 6ce2cc619c079ce207b8266e26165464f4af28b2 (diff) | |
parent | 223d8a3d26a7561fcae9536efbf120d7c4760bd4 (diff) |
Merge branch 'zero-downtime-migrations' into 'master'
Prepare for zero downtime migrations
See merge request !9976
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/concerns/ignorable_column_spec.rb | 38 |
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 |