Merge remote-tracking branch 'upstream/master'

Conflicts:
	spec/spec_helper.rb
This commit is contained in:
Alejandro Babio 2013-12-06 07:53:24 -03:00
commit c1e531a9a4
4 changed files with 25 additions and 0 deletions

View File

@ -180,10 +180,15 @@ module Ransack
def strip_predicate_and_index(str)
string = str.split(/\(/).first
string = strip_before_type_cast(string)
Predicate.detect_and_strip_from_string!(string)
string
end
def strip_before_type_cast(str)
str.split("_before_type_cast").first
end
end
end
end

View File

@ -1,3 +1,5 @@
Note.blueprint do
note
notable_type { "Article" }
notable_id
end

View File

@ -7,6 +7,7 @@ module Ransack
router = ActionDispatch::Routing::RouteSet.new
router.draw do
resources :people
resources :notes
get ':controller(/:action(/:id(.:format)))'
end
@ -132,6 +133,22 @@ module Ransack
end
end
end
context 'fields used in polymorphic relations as search attributes in form' do
before do
@controller.view_context.search_form_for Note.search do |f|
@f = f
end
end
it 'accepts poly_id field' do
html = @f.text_field(:notable_id_eq)
html.should match /id=\"q_notable_id_eq\"/
end
it 'accepts poly_type field' do
html = @f.text_field(:notable_type_eq)
html.should match /id=\"q_notable_type_eq\"/
end
end
end
end
end

View File

@ -20,6 +20,7 @@ Sham.define do
only_admin { Faker::Lorem.words(3).join(' ') }
only_search { Faker::Lorem.words(3).join(' ') }
only_sort { Faker::Lorem.words(3).join(' ') }
notable_id { |id| id }
end
RSpec.configure do |config|