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
path: root/spec
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-09-20 22:30:55 +0300
committerNick Thomas <nick@gitlab.com>2018-09-20 22:30:55 +0300
commitc2da94187d506e03289a5851b576caa36eb2d4ca (patch)
tree31a84595ada44cc9169bd868ca3c92c3c09cb5af /spec
parent732538c4d9aa3227aea740b3d13a10b2c0a36b29 (diff)
parentce830d3c60fbf445c67fb923f03678ad2333eba5 (diff)
Merge branch 'tc-geo-prune-events-correctly-ce' into 'master'
Add Gitlab::Database::Subquery.self_join to delete_all with limit See merge request gitlab-org/gitlab-ce!21839
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/database/subquery_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database/subquery_spec.rb b/spec/lib/gitlab/database/subquery_spec.rb
new file mode 100644
index 00000000000..70380e02f16
--- /dev/null
+++ b/spec/lib/gitlab/database/subquery_spec.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::Database::Subquery do
+ describe '.self_join' do
+ set(:project) { create(:project) }
+
+ it 'allows you to delete_all rows with WHERE and LIMIT' do
+ events = create_list(:event, 8, project: project)
+
+ expect do
+ described_class.self_join(Event.where('id < ?', events[5]).recent.limit(2)).delete_all
+ end.to change { Event.count }.by(-2)
+ end
+ end
+end