spec/mongoid/adapters/mongoid/base_spec.rb in ransack-1.8.2 vs spec/mongoid/adapters/mongoid/base_spec.rb in ransack-1.8.3
- old
+ new
@@ -63,10 +63,31 @@
expect(s.result.to_a).to eq [p]
s = Person.ransack(term_cont: 'nomatch')
expect(s.result.to_a).to eq []
end
+
+ it 'makes aliases available to subclasses' do
+ yngwie = Musician.create!(name: 'Yngwie Malmsteen')
+
+ musicians = Musician.ransack(term_cont: 'ngw').result
+ expect(musicians).to eq([yngwie])
+ end
+
+ it 'handles naming collisions gracefully' do
+ frank = Person.create!(name: 'Frank Stallone')
+
+ people = Person.ransack(term_cont: 'allon').result
+ expect(people).to eq([frank])
+
+ Class.new(Article) do
+ ransack_alias :term, :title
+ end
+
+ people = Person.ransack(term_cont: 'allon').result
+ expect(people).to eq([frank])
+ end
end
describe '#ransacker' do
# For infix tests
def self.sane_adapter?
@@ -272,11 +293,9 @@
it { should include 'only_admin' }
end
end
describe '#ransackable_associations' do
- before { pending "not implemented for mongoid" }
-
subject { Person.ransackable_associations }
it { should include 'parent' }
it { should include 'children' }
it { should include 'articles' }