diff options
Diffstat (limited to 'spec/lib/unnested_in_filters/dsl_spec.rb')
-rw-r--r-- | spec/lib/unnested_in_filters/dsl_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/lib/unnested_in_filters/dsl_spec.rb b/spec/lib/unnested_in_filters/dsl_spec.rb new file mode 100644 index 00000000000..bce4c88f94c --- /dev/null +++ b/spec/lib/unnested_in_filters/dsl_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe UnnestedInFilters::Dsl do + let(:test_model) do + Class.new(ApplicationRecord) do + include UnnestedInFilters::Dsl + + self.table_name = 'users' + end + end + + describe '#exists?' do + let(:states) { %w(active banned) } + + subject { test_model.where(state: states).use_unnested_filters.exists? } + + context 'when there is no record in the database with given filters' do + it { is_expected.to be_falsey } + end + + context 'when there is a record in the database with given filters' do + before do + create(:user, state: :active) + end + + it { is_expected.to be_truthy } + end + end +end |