Skip to content

Commit debfec8

Browse files
committed
add test to ensure ransack works as expected
1 parent 92dbda5 commit debfec8

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

spec/filtering_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
end
1313
end
1414

15-
context 'attributes with underscore in name' do
15+
context 'handle attributes with underscore in name' do
1616
it 'detect _' do
1717
attributes, predicates = JSONAPI::Filtering
1818
.extract_attributes_and_predicates('notes_count_eq')
@@ -103,6 +103,13 @@
103103
}
104104
end
105105

106+
it 'ensures ransack scopes work properly' do
107+
ransack = User.ransack(notes_count_eq: 1)
108+
expected_sql = 'SELECT "users".* FROM "users" WHERE '\
109+
'"users"."notes_count" = 1'
110+
expect(ransack.result.to_sql).to eq(expected_sql)
111+
end
112+
106113
it do
107114
expect(first_user.notes_count).to eq(0)
108115
expect(second_user.notes_count).to eq(1)

0 commit comments

Comments
 (0)