Sha256: d41d6de84416fb15e9c919440ab70b934005db695e333bafc0cfeda731c6e71b
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
require 'spec_helper' describe CountriesController, '-> Ransack query search', type: :controller do it 'Filter by q[name_eq]' do 3.times { create :country } country = Country.first get :index, q: {name_eq: country.name} response.should be_success assigns(:countries).should eq [country] end it 'Filter by attribute, predicate and value' do 3.times { create :country } country = Country.first get :index, q: {c: [{a: {'0' => {name: 'name'}}, p: 'eq', v: {'0' => {value: country.name}}}]} response.should be_success assigns(:countries).should eq [country] end it 'Filter by NQL' do 3.times { create :country } country = Country.first get :index, q: "name = #{country.name}" response.should be_success assigns(:countries).should eq [country] end it 'Filter by NQL with invalid field' do 3.times { create :country } country = Country.first get :index, q: "abcd = #{country.name}" response.should be_success assigns(:countries).should eq [] end it 'Filter by NQL with invalid expression' do 3.times { create :country } get :index, q: 'abcd = ' response.should be_success assigns(:countries).should eq [] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dynamic_controller-0.0.8 | spec/controllers/ransack_spec.rb |
dynamic_controller-0.0.7 | spec/controllers/ransack_spec.rb |