@@ -50,6 +50,21 @@ module Mongoid
50
50
end
51
51
end
52
52
53
+ describe '#ransack_alias' do
54
+ it 'translates an alias to the correct attributes' do
55
+ p = Person . create! ( name :
'Meatloaf' , email :
'[email protected] ' )
56
+
57
+ s = Person . ransack ( term_cont : 'atlo' )
58
+ expect ( s . result . to_a ) . to eq [ p ]
59
+
60
+ s = Person . ransack ( term_cont : 'babi' )
61
+ expect ( s . result . to_a ) . to eq [ p ]
62
+
63
+ s = Person . ransack ( term_cont : 'nomatch' )
64
+ expect ( s . result . to_a ) . to eq [ ]
65
+ end
66
+ end
67
+
53
68
describe '#ransacker' do
54
69
# For infix tests
55
70
def self . sane_adapter?
@@ -213,6 +228,7 @@ def self.sane_adapter?
213
228
it { should include 'name' }
214
229
it { should include 'reversed_name' }
215
230
it { should include 'doubled_name' }
231
+ it { should include 'term' }
216
232
it { should include 'only_search' }
217
233
it { should_not include 'only_sort' }
218
234
it { should_not include 'only_admin' }
@@ -224,6 +240,7 @@ def self.sane_adapter?
224
240
it { should include 'name' }
225
241
it { should include 'reversed_name' }
226
242
it { should include 'doubled_name' }
243
+ it { should include 'term' }
227
244
it { should include 'only_search' }
228
245
it { should_not include 'only_sort' }
229
246
it { should include 'only_admin' }
0 commit comments