Welcome to mirror list, hosted at ThFree Co, Russian Federation.

subquery_spec.rb « database « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 70380e02f16d5debb602dfd9716314702d70f1b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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