summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/database/migration_helpers_spec.rb
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-05-26 18:25:32 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-05-26 18:25:32 +0800
commit70eb0c6a88ccb4a1d8fe6cc42fa4aa72b7584ffe (patch)
tree9a5b4fefcec414bc8b017e672dfc2f535383a4a5 /spec/lib/gitlab/database/migration_helpers_spec.rb
parentec525efddba67d840cc409aa4b9a8857dac7453f (diff)
parent7a509c26dd9972f74d030504c292f36b480511f0 (diff)
downloadgitlab-ce-70eb0c6a88ccb4a1d8fe6cc42fa4aa72b7584ffe.tar.gz
Merge remote-tracking branch 'upstream/master' into rename-builds-controller
* upstream/master: (307 commits) Address feedback Add small update for the i18n guide. update webpack to v2.6.1 patch release to fix "Can't find variable: Promise" error update webpack-bundle-analyzer past v2.4.1 to support NamedChunksPlugin name all webpack chunks to improve long term cacheability add NameAllModulesPlugin to cover shortcomings of NamedModulesPlugin upgrade to latest webpack version Only use DROP INDEX CONCURRENTLY on postgreql 9.2+ Provide default for calculating label text color (!11681) Add failing test for #32728 Bugfix: Always use the default language when generating emails. Remove unecessary commit pattern check Add regexp_for_value helper method Remove shared example and improve sub_group_issuables_spec.rb Remove 'should' from scenario in has_subgroup_title_spec.rb Cartfile git and binary methods cannot take a GitHub repo Fix terminals support for Kubernetes service Add review comments to compare_spec.rb Fix transient error clicking dropdown items in compare_spec.rb Use non-global jQuery reference within raven bundle ...
Diffstat (limited to 'spec/lib/gitlab/database/migration_helpers_spec.rb')
-rw-r--r--spec/lib/gitlab/database/migration_helpers_spec.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb
index dfa3ae9142e..3fdafd867da 100644
--- a/spec/lib/gitlab/database/migration_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migration_helpers_spec.rb
@@ -66,16 +66,23 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
context 'using PostgreSQL' do
before do
- allow(Gitlab::Database).to receive(:postgresql?).and_return(true)
+ allow(model).to receive(:supports_drop_index_concurrently?).and_return(true)
allow(model).to receive(:disable_statement_timeout)
end
- it 'removes the index concurrently' do
+ it 'removes the index concurrently by column name' do
expect(model).to receive(:remove_index).
with(:users, { algorithm: :concurrently, column: :foo })
model.remove_concurrent_index(:users, :foo)
end
+
+ it 'removes the index concurrently by index name' do
+ expect(model).to receive(:remove_index).
+ with(:users, { algorithm: :concurrently, name: "index_x_by_y" })
+
+ model.remove_concurrent_index_by_name(:users, "index_x_by_y")
+ end
end
context 'using MySQL' do
@@ -247,6 +254,14 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
expect(Project.where(archived: true).count).to eq(1)
end
end
+
+ context 'when the value is Arel.sql (Arel::Nodes::SqlLiteral)' do
+ it 'updates the value as a SQL expression' do
+ model.update_column_in_batches(:projects, :star_count, Arel.sql('1+1'))
+
+ expect(Project.sum(:star_count)).to eq(2 * Project.count)
+ end
+ end
end
describe '#add_column_with_default' do