blob: 9f1552b02ec66f34b120858348799354096fe9f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
|