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

constraints_spec.rb « relation_parsers « names_suggestions « metrics « usage « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 68016e760e4e9b154f19007ba832aac6d8435389 (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::Usage::Metrics::NamesSuggestions::RelationParsers::Constraints do
  describe '#accept' do
    let(:collector) { Arel::Collectors::SubstituteBinds.new(ActiveRecord::Base.connection, Arel::Collectors::SQLString.new) }

    it 'builds correct constraints description' do
      table = Arel::Table.new('records')
      arel = table.from.project(table['id'].count).where(table[:attribute].eq(true).and(table[:some_value].gt(5)))
      described_class.new(ApplicationRecord.connection).accept(arel, collector)

      expect(collector.value).to eql '(records.attribute = true AND records.some_value > 5)'
    end
  end
end