summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/usage/metrics/names_suggestions/relation_parsers/constraints_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/usage/metrics/names_suggestions/relation_parsers/constraints_spec.rb')
-rw-r--r--spec/lib/gitlab/usage/metrics/names_suggestions/relation_parsers/constraints_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/lib/gitlab/usage/metrics/names_suggestions/relation_parsers/constraints_spec.rb b/spec/lib/gitlab/usage/metrics/names_suggestions/relation_parsers/constraints_spec.rb
new file mode 100644
index 00000000000..68016e760e4
--- /dev/null
+++ b/spec/lib/gitlab/usage/metrics/names_suggestions/relation_parsers/constraints_spec.rb
@@ -0,0 +1,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