rails3-jquery-autocomplete 0.6.6 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/README.markdown +10 -0
- data/integration/Gemfile +7 -6
- data/integration/Gemfile.lock +3 -1
- data/integration/app/controllers/scoped_autocompletes_controller.rb +7 -0
- data/integration/app/models/brand.rb +13 -0
- data/integration/app/models/feature.rb +11 -0
- data/integration/app/models/foreign_brand.rb +12 -0
- data/integration/app/models/product.rb +11 -0
- data/integration/app/views/scoped_autocompletes/new.html.haml +10 -0
- data/integration/config/routes.rb +64 -0
- data/integration/db/migrate/20110423000347_add_state_to_brands.rb +9 -0
- data/integration/db/schema.rb +2 -1
- data/integration/features/autocomplete.feature +13 -5
- data/lib/rails3-jquery-autocomplete/autocomplete.rb +4 -0
- data/lib/rails3-jquery-autocomplete/helpers.rb +16 -10
- data/lib/rails3-jquery-autocomplete/version.rb +1 -1
- data/rails3-jquery-autocomplete.gemspec +2 -2
- data/test/implementations_test.rb +0 -1
- data/test/support/mongoid.rb +2 -3
- metadata +14 -16
- data/Gemfile.lock +0 -97
- data/test/helpers.rb +0 -122
data/.gitignore
CHANGED
data/README.markdown
CHANGED
@@ -139,6 +139,15 @@ This wouldn't really make much sense unless you use it with the :id_element HTML
|
|
139
139
|
|
140
140
|
Only the object's id and the column you are searching on will be returned in JSON, so if your display_value method requires another parameter, make sure to fetch it with the :extra_data option
|
141
141
|
|
142
|
+
|
143
|
+
#### :scopes
|
144
|
+
Added option to use scopes. Pass scopes in an array.
|
145
|
+
e.g `:scopes => [:scope1, :scope2]`
|
146
|
+
|
147
|
+
#### :column_name
|
148
|
+
By default autocomplete uses method name as column name. Now it can be specified using column_name options
|
149
|
+
`:column_name => 'name'`
|
150
|
+
|
142
151
|
### View
|
143
152
|
|
144
153
|
On your view, all you have to do is include the attribute autocomplete on the text field
|
@@ -288,3 +297,4 @@ Everyone on [this list](https://github.com/crowdint/rails3-jquery-autocomplete/c
|
|
288
297
|
[Crowd Interactive](http://www.crowdint.com) is an American web design and development company that happens to work in Colima, Mexico.
|
289
298
|
We specialize in building and growing online retail stores. We don’t work with everyone – just companies we believe in. Call us today to see if there’s a fit.
|
290
299
|
Find more info [here](http://www.crowdint.com)!
|
300
|
+
|
data/integration/Gemfile
CHANGED
@@ -2,14 +2,15 @@ source 'http://rubygems.org'
|
|
2
2
|
|
3
3
|
gem 'rails', '~>3.0.3'
|
4
4
|
|
5
|
-
gem '
|
6
|
-
gem 'cucumber-rails', '~>0.3.2'
|
5
|
+
gem 'annotate'
|
7
6
|
gem 'capybara', '~>0.4.0'
|
8
|
-
gem '
|
9
|
-
gem '
|
7
|
+
gem 'cucumber-rails', '~>0.3.2'
|
8
|
+
gem 'database_cleaner'
|
10
9
|
gem 'haml-rails'
|
11
10
|
gem 'jquery-rails'
|
12
|
-
gem 'pickle'
|
13
|
-
gem 'database_cleaner'
|
14
11
|
gem 'launchy'
|
12
|
+
gem 'nifty-generators'
|
13
|
+
gem 'pickle'
|
14
|
+
gem 'rails3-jquery-autocomplete', :path => '../'
|
15
15
|
gem 'simple_form'
|
16
|
+
gem 'sqlite3-ruby', :require => 'sqlite3'
|
data/integration/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../
|
3
3
|
specs:
|
4
|
-
rails3-jquery-autocomplete (0.6.
|
4
|
+
rails3-jquery-autocomplete (0.6.6)
|
5
5
|
rails (~> 3.0.0)
|
6
6
|
yajl-ruby
|
7
7
|
|
@@ -35,6 +35,7 @@ GEM
|
|
35
35
|
activemodel (= 3.0.4)
|
36
36
|
activesupport (= 3.0.4)
|
37
37
|
activesupport (3.0.4)
|
38
|
+
annotate (2.4.0)
|
38
39
|
arel (2.0.8)
|
39
40
|
builder (2.1.2)
|
40
41
|
capybara (0.4.0)
|
@@ -146,6 +147,7 @@ PLATFORMS
|
|
146
147
|
ruby
|
147
148
|
|
148
149
|
DEPENDENCIES
|
150
|
+
annotate
|
149
151
|
capybara (~> 0.4.0)
|
150
152
|
cucumber-rails (~> 0.3.2)
|
151
153
|
database_cleaner
|
@@ -1,2 +1,15 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: brands
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# name :string(255)
|
7
|
+
# created_at :datetime
|
8
|
+
# updated_at :datetime
|
9
|
+
# type :string(255)
|
10
|
+
# state :boolean
|
11
|
+
#
|
12
|
+
|
1
13
|
class Brand < ActiveRecord::Base
|
14
|
+
scope :active, where(:state => true)
|
2
15
|
end
|
@@ -1,3 +1,15 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: brands
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# name :string(255)
|
7
|
+
# created_at :datetime
|
8
|
+
# updated_at :datetime
|
9
|
+
# type :string(255)
|
10
|
+
# state :boolean
|
11
|
+
#
|
12
|
+
|
1
13
|
class ForeignBrand < Brand
|
2
14
|
|
3
15
|
end
|
@@ -1,3 +1,14 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: products
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# name :string(255)
|
7
|
+
# brand_name :string(255)
|
8
|
+
# created_at :datetime
|
9
|
+
# updated_at :datetime
|
10
|
+
#
|
11
|
+
|
1
12
|
class Product < ActiveRecord::Base
|
2
13
|
attr_accessor :brand_id
|
3
14
|
|
@@ -23,4 +23,68 @@ Integration::Application.routes.draw do
|
|
23
23
|
resources :simple_forms do
|
24
24
|
get :autocomplete_feature_name, :on => :collection
|
25
25
|
end
|
26
|
+
|
27
|
+
resources :scoped_autocompletes do
|
28
|
+
get :autocomplete_brand_name, :on => :collection
|
29
|
+
end
|
26
30
|
end
|
31
|
+
#== Route Map
|
32
|
+
# Generated on 25 Apr 2011 09:55
|
33
|
+
#
|
34
|
+
# root /(.:format) {:controller=>"autocomplete", :action=>"new"}
|
35
|
+
# autocomplete_autocomplete_brand_name /autocomplete/autocomplete_brand_name(.:format) {:controller=>"autocomplete", :action=>"autocomplete_brand_name"}
|
36
|
+
# products GET /products(.:format) {:controller=>"products", :action=>"index"}
|
37
|
+
# POST /products(.:format) {:controller=>"products", :action=>"create"}
|
38
|
+
# new_product GET /products/new(.:format) {:controller=>"products", :action=>"new"}
|
39
|
+
# edit_product GET /products/:id/edit(.:format) {:controller=>"products", :action=>"edit"}
|
40
|
+
# product GET /products/:id(.:format) {:controller=>"products", :action=>"show"}
|
41
|
+
# PUT /products/:id(.:format) {:controller=>"products", :action=>"update"}
|
42
|
+
# DELETE /products/:id(.:format) {:controller=>"products", :action=>"destroy"}
|
43
|
+
# autocomplete_brand_name_id_elements GET /id_elements/autocomplete_brand_name(.:format) {:controller=>"id_elements", :action=>"autocomplete_brand_name"}
|
44
|
+
# id_elements GET /id_elements(.:format) {:controller=>"id_elements", :action=>"index"}
|
45
|
+
# POST /id_elements(.:format) {:controller=>"id_elements", :action=>"create"}
|
46
|
+
# new_id_element GET /id_elements/new(.:format) {:controller=>"id_elements", :action=>"new"}
|
47
|
+
# edit_id_element GET /id_elements/:id/edit(.:format) {:controller=>"id_elements", :action=>"edit"}
|
48
|
+
# id_element GET /id_elements/:id(.:format) {:controller=>"id_elements", :action=>"show"}
|
49
|
+
# PUT /id_elements/:id(.:format) {:controller=>"id_elements", :action=>"update"}
|
50
|
+
# DELETE /id_elements/:id(.:format) {:controller=>"id_elements", :action=>"destroy"}
|
51
|
+
# autocomplete_foreign_brand_name_sub_classes GET /sub_classes/autocomplete_foreign_brand_name(.:format) {:controller=>"sub_classes", :action=>"autocomplete_foreign_brand_name"}
|
52
|
+
# sub_classes GET /sub_classes(.:format) {:controller=>"sub_classes", :action=>"index"}
|
53
|
+
# POST /sub_classes(.:format) {:controller=>"sub_classes", :action=>"create"}
|
54
|
+
# new_sub_class GET /sub_classes/new(.:format) {:controller=>"sub_classes", :action=>"new"}
|
55
|
+
# edit_sub_class GET /sub_classes/:id/edit(.:format) {:controller=>"sub_classes", :action=>"edit"}
|
56
|
+
# sub_class GET /sub_classes/:id(.:format) {:controller=>"sub_classes", :action=>"show"}
|
57
|
+
# PUT /sub_classes/:id(.:format) {:controller=>"sub_classes", :action=>"update"}
|
58
|
+
# DELETE /sub_classes/:id(.:format) {:controller=>"sub_classes", :action=>"destroy"}
|
59
|
+
# autocomplete_brand_name_multiple_selections GET /multiple_selections/autocomplete_brand_name(.:format) {:controller=>"multiple_selections", :action=>"autocomplete_brand_name"}
|
60
|
+
# multiple_selections GET /multiple_selections(.:format) {:controller=>"multiple_selections", :action=>"index"}
|
61
|
+
# POST /multiple_selections(.:format) {:controller=>"multiple_selections", :action=>"create"}
|
62
|
+
# new_multiple_selection GET /multiple_selections/new(.:format) {:controller=>"multiple_selections", :action=>"new"}
|
63
|
+
# edit_multiple_selection GET /multiple_selections/:id/edit(.:format) {:controller=>"multiple_selections", :action=>"edit"}
|
64
|
+
# multiple_selection GET /multiple_selections/:id(.:format) {:controller=>"multiple_selections", :action=>"show"}
|
65
|
+
# PUT /multiple_selections/:id(.:format) {:controller=>"multiple_selections", :action=>"update"}
|
66
|
+
# DELETE /multiple_selections/:id(.:format) {:controller=>"multiple_selections", :action=>"destroy"}
|
67
|
+
# autocomplete_feature_name_nested_models GET /nested_models/autocomplete_feature_name(.:format) {:controller=>"nested_models", :action=>"autocomplete_feature_name"}
|
68
|
+
# nested_models GET /nested_models(.:format) {:controller=>"nested_models", :action=>"index"}
|
69
|
+
# POST /nested_models(.:format) {:controller=>"nested_models", :action=>"create"}
|
70
|
+
# new_nested_model GET /nested_models/new(.:format) {:controller=>"nested_models", :action=>"new"}
|
71
|
+
# edit_nested_model GET /nested_models/:id/edit(.:format) {:controller=>"nested_models", :action=>"edit"}
|
72
|
+
# nested_model GET /nested_models/:id(.:format) {:controller=>"nested_models", :action=>"show"}
|
73
|
+
# PUT /nested_models/:id(.:format) {:controller=>"nested_models", :action=>"update"}
|
74
|
+
# DELETE /nested_models/:id(.:format) {:controller=>"nested_models", :action=>"destroy"}
|
75
|
+
# autocomplete_feature_name_simple_forms GET /simple_forms/autocomplete_feature_name(.:format) {:controller=>"simple_forms", :action=>"autocomplete_feature_name"}
|
76
|
+
# simple_forms GET /simple_forms(.:format) {:controller=>"simple_forms", :action=>"index"}
|
77
|
+
# POST /simple_forms(.:format) {:controller=>"simple_forms", :action=>"create"}
|
78
|
+
# new_simple_form GET /simple_forms/new(.:format) {:controller=>"simple_forms", :action=>"new"}
|
79
|
+
# edit_simple_form GET /simple_forms/:id/edit(.:format) {:controller=>"simple_forms", :action=>"edit"}
|
80
|
+
# simple_form GET /simple_forms/:id(.:format) {:controller=>"simple_forms", :action=>"show"}
|
81
|
+
# PUT /simple_forms/:id(.:format) {:controller=>"simple_forms", :action=>"update"}
|
82
|
+
# DELETE /simple_forms/:id(.:format) {:controller=>"simple_forms", :action=>"destroy"}
|
83
|
+
# autocomplete_brand_name_scoped_autocompletes GET /scoped_autocompletes/autocomplete_brand_name(.:format) {:controller=>"scoped_autocompletes", :action=>"autocomplete_brand_name"}
|
84
|
+
# scoped_autocompletes GET /scoped_autocompletes(.:format) {:controller=>"scoped_autocompletes", :action=>"index"}
|
85
|
+
# POST /scoped_autocompletes(.:format) {:controller=>"scoped_autocompletes", :action=>"create"}
|
86
|
+
# new_scoped_autocomplete GET /scoped_autocompletes/new(.:format) {:controller=>"scoped_autocompletes", :action=>"new"}
|
87
|
+
# edit_scoped_autocomplete GET /scoped_autocompletes/:id/edit(.:format) {:controller=>"scoped_autocompletes", :action=>"edit"}
|
88
|
+
# scoped_autocomplete GET /scoped_autocompletes/:id(.:format) {:controller=>"scoped_autocompletes", :action=>"show"}
|
89
|
+
# PUT /scoped_autocompletes/:id(.:format) {:controller=>"scoped_autocompletes", :action=>"update"}
|
90
|
+
# DELETE /scoped_autocompletes/:id(.:format) {:controller=>"scoped_autocompletes", :action=>"destroy"}
|
data/integration/db/schema.rb
CHANGED
@@ -10,13 +10,14 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended to check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(:version =>
|
13
|
+
ActiveRecord::Schema.define(:version => 20110423000347) do
|
14
14
|
|
15
15
|
create_table "brands", :force => true do |t|
|
16
16
|
t.string "name"
|
17
17
|
t.datetime "created_at"
|
18
18
|
t.datetime "updated_at"
|
19
19
|
t.string "type"
|
20
|
+
t.boolean "state"
|
20
21
|
end
|
21
22
|
|
22
23
|
create_table "features", :force => true do |t|
|
@@ -3,12 +3,14 @@ Feature: Autocomplete
|
|
3
3
|
As a User
|
4
4
|
I want autocomplete!
|
5
5
|
|
6
|
-
Background:
|
6
|
+
Background:
|
7
7
|
Given the following brands exists:
|
8
|
-
| name
|
9
|
-
| Alpha |
|
10
|
-
| Beta
|
11
|
-
| Gamma |
|
8
|
+
| name | state |
|
9
|
+
| Alpha | 1 |
|
10
|
+
| Beta | 0 |
|
11
|
+
| Gamma | 0 |
|
12
|
+
| Kappa | 1 |
|
13
|
+
| Kappler | 0 |
|
12
14
|
And the following features exists:
|
13
15
|
| name |
|
14
16
|
| Shiny |
|
@@ -62,3 +64,9 @@ Feature: Autocomplete
|
|
62
64
|
And I choose "Alpha" in the autocomplete list
|
63
65
|
Then the "Brand name" field should contain "Alpha"
|
64
66
|
|
67
|
+
@javascript
|
68
|
+
Scenario: Autocomplete with scope
|
69
|
+
Given I go to the new scoped autocomplete page
|
70
|
+
And I fill in "Brand name" with "ka"
|
71
|
+
And I choose "Kappa" in the autocomplete list
|
72
|
+
Then the "Brand name" field should contain "Kappa"
|
@@ -27,6 +27,9 @@ module Rails3JQueryAutocomplete
|
|
27
27
|
|
28
28
|
define_method("autocomplete_#{object}_#{method}") do
|
29
29
|
|
30
|
+
|
31
|
+
method = options[:column_name] if options.has_key?(:column_name)
|
32
|
+
|
30
33
|
term = params[:term]
|
31
34
|
|
32
35
|
if term && !term.empty?
|
@@ -44,3 +47,4 @@ module Rails3JQueryAutocomplete
|
|
44
47
|
end
|
45
48
|
|
46
49
|
end
|
50
|
+
|
@@ -89,27 +89,33 @@ module Rails3JQueryAutocomplete
|
|
89
89
|
# items = get_autocomplete_items(:model => get_object(object), :options => options, :term => term, :method => method)
|
90
90
|
#
|
91
91
|
def get_autocomplete_items(parameters)
|
92
|
-
model
|
93
|
-
|
92
|
+
model = parameters[:model]
|
93
|
+
term = parameters[:term]
|
94
|
+
method = parameters[:method]
|
94
95
|
options = parameters[:options]
|
95
|
-
term = parameters[:term]
|
96
|
-
is_full_search = options[:full]
|
97
96
|
|
98
|
-
|
97
|
+
is_full_search = options[:full]
|
98
|
+
scopes = Array(options[:scopes])
|
99
|
+
limit = get_autocomplete_limit(options)
|
99
100
|
implementation = get_implementation(model)
|
100
|
-
order
|
101
|
+
order = get_autocomplete_order(implementation, method, options)
|
101
102
|
|
102
103
|
like_clause = (defined?(PGconn) ? 'ILIKE' : 'LIKE')
|
103
104
|
|
105
|
+
items = model.scoped
|
106
|
+
|
107
|
+
scopes.each { |scope| items = items.send(scope) } unless scopes.empty?
|
108
|
+
|
104
109
|
case implementation
|
105
110
|
when :mongoid
|
106
111
|
search = (is_full_search ? '.*' : '^') + term + '.*'
|
107
|
-
items
|
112
|
+
items = model.where(method.to_sym => /#{search}/i).limit(limit).order_by(order)
|
108
113
|
when :activerecord
|
109
|
-
|
110
|
-
items =
|
111
|
-
|
114
|
+
items = items.select([:id, method] + (options[:extra_data].blank? ? [] : options[:extra_data])) unless options[:full_model]
|
115
|
+
items = items.where(["LOWER(#{method}) #{like_clause} ?", "#{(is_full_search ? '%' : '')}#{term.downcase}%"]) \
|
116
|
+
.limit(limit).order(order)
|
112
117
|
end
|
113
118
|
end
|
114
119
|
end
|
115
120
|
end
|
121
|
+
|
@@ -16,8 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.add_dependency('yajl-ruby')
|
17
17
|
|
18
18
|
s.add_development_dependency('sqlite3-ruby')
|
19
|
-
s.add_development_dependency('mongoid', '>= 2.0.0
|
20
|
-
s.add_development_dependency('bson_ext', '~>1.
|
19
|
+
s.add_development_dependency('mongoid', '>= 2.0.0')
|
20
|
+
s.add_development_dependency('bson_ext', '~>1.3.0')
|
21
21
|
s.add_development_dependency('shoulda', '~>2.11.1')
|
22
22
|
|
23
23
|
s.files = `git ls-files`.split("\n")
|
@@ -9,7 +9,6 @@ class ActiveRecordControllerTest < ActionController::TestCase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
class ActiveRecordSTIControllerTest < ActionController::TestCase
|
12
|
-
require 'support/active_record'
|
13
12
|
include Rails3JQueryAutocomplete::TestCase::ActiveRecord
|
14
13
|
include Rails3JQueryAutocomplete::TestCase
|
15
14
|
|
data/test/support/mongoid.rb
CHANGED
@@ -9,10 +9,9 @@ module Rails3JQueryAutocomplete
|
|
9
9
|
config.logger = nil
|
10
10
|
end
|
11
11
|
|
12
|
-
create_models
|
12
|
+
create_models
|
13
13
|
|
14
14
|
@controller = ActorsController.new
|
15
|
-
|
16
15
|
@movie1 = @movie_class.create(:name => 'Alpha')
|
17
16
|
@movie2 = @movie_class.create(:name => 'Alspha')
|
18
17
|
@movie3 = @movie_class.create(:name => 'Alzpha')
|
@@ -36,7 +35,7 @@ module Rails3JQueryAutocomplete
|
|
36
35
|
end
|
37
36
|
|
38
37
|
def destroy_models
|
39
|
-
Object.send(:remove_const, :Movie)
|
38
|
+
Object.send(:remove_const, :Movie)
|
40
39
|
end
|
41
40
|
|
42
41
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails3-jquery-autocomplete
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 7
|
9
|
+
- 0
|
10
|
+
version: 0.7.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Padilla
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-25 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -70,14 +70,12 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
hash:
|
73
|
+
hash: 15
|
74
74
|
segments:
|
75
75
|
- 2
|
76
76
|
- 0
|
77
77
|
- 0
|
78
|
-
|
79
|
-
- 7
|
80
|
-
version: 2.0.0.rc.7
|
78
|
+
version: 2.0.0
|
81
79
|
type: :development
|
82
80
|
version_requirements: *id004
|
83
81
|
- !ruby/object:Gem::Dependency
|
@@ -88,12 +86,12 @@ dependencies:
|
|
88
86
|
requirements:
|
89
87
|
- - ~>
|
90
88
|
- !ruby/object:Gem::Version
|
91
|
-
hash:
|
89
|
+
hash: 27
|
92
90
|
segments:
|
93
91
|
- 1
|
94
|
-
-
|
95
|
-
-
|
96
|
-
version: 1.
|
92
|
+
- 3
|
93
|
+
- 0
|
94
|
+
version: 1.3.0
|
97
95
|
type: :development
|
98
96
|
version_requirements: *id005
|
99
97
|
- !ruby/object:Gem::Dependency
|
@@ -124,7 +122,6 @@ files:
|
|
124
122
|
- .document
|
125
123
|
- .gitignore
|
126
124
|
- Gemfile
|
127
|
-
- Gemfile.lock
|
128
125
|
- LICENSE
|
129
126
|
- README.markdown
|
130
127
|
- Rakefile
|
@@ -138,6 +135,7 @@ files:
|
|
138
135
|
- integration/app/controllers/id_elements_controller.rb
|
139
136
|
- integration/app/controllers/multiple_selections_controller.rb
|
140
137
|
- integration/app/controllers/nested_models_controller.rb
|
138
|
+
- integration/app/controllers/scoped_autocompletes_controller.rb
|
141
139
|
- integration/app/controllers/simple_forms_controller.rb
|
142
140
|
- integration/app/controllers/sub_classes_controller.rb
|
143
141
|
- integration/app/helpers/application_helper.rb
|
@@ -155,6 +153,7 @@ files:
|
|
155
153
|
- integration/app/views/layouts/application.html.haml
|
156
154
|
- integration/app/views/multiple_selections/new.html.haml
|
157
155
|
- integration/app/views/nested_models/new.html.haml
|
156
|
+
- integration/app/views/scoped_autocompletes/new.html.haml
|
158
157
|
- integration/app/views/simple_forms/new.html.haml
|
159
158
|
- integration/app/views/sub_classes/new.html.haml
|
160
159
|
- integration/config.ru
|
@@ -177,6 +176,7 @@ files:
|
|
177
176
|
- integration/db/migrate/20101209014355_create_products.rb
|
178
177
|
- integration/db/migrate/20101209053936_add_type_to_brand.rb
|
179
178
|
- integration/db/migrate/20110209020136_create_features.rb
|
179
|
+
- integration/db/migrate/20110423000347_add_state_to_brands.rb
|
180
180
|
- integration/db/schema.rb
|
181
181
|
- integration/db/seeds.rb
|
182
182
|
- integration/doc/README_FOR_APP
|
@@ -218,7 +218,6 @@ files:
|
|
218
218
|
- rails3-jquery-autocomplete.gemspec
|
219
219
|
- test/form_helper_test.rb
|
220
220
|
- test/generators/generator_test.rb
|
221
|
-
- test/helpers.rb
|
222
221
|
- test/implementations_test.rb
|
223
222
|
- test/support/active_record.rb
|
224
223
|
- test/support/mongoid.rb
|
@@ -261,7 +260,6 @@ summary: Use jQuery's autocomplete plugin with Rails 3.
|
|
261
260
|
test_files:
|
262
261
|
- test/form_helper_test.rb
|
263
262
|
- test/generators/generator_test.rb
|
264
|
-
- test/helpers.rb
|
265
263
|
- test/implementations_test.rb
|
266
264
|
- test/support/active_record.rb
|
267
265
|
- test/support/mongoid.rb
|
data/Gemfile.lock
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
rails3-jquery-autocomplete (0.6.6)
|
5
|
-
rails (~> 3.0.0)
|
6
|
-
yajl-ruby
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: http://rubygems.org/
|
10
|
-
specs:
|
11
|
-
abstract (1.0.0)
|
12
|
-
actionmailer (3.0.5)
|
13
|
-
actionpack (= 3.0.5)
|
14
|
-
mail (~> 2.2.15)
|
15
|
-
actionpack (3.0.5)
|
16
|
-
activemodel (= 3.0.5)
|
17
|
-
activesupport (= 3.0.5)
|
18
|
-
builder (~> 2.1.2)
|
19
|
-
erubis (~> 2.6.6)
|
20
|
-
i18n (~> 0.4)
|
21
|
-
rack (~> 1.2.1)
|
22
|
-
rack-mount (~> 0.6.13)
|
23
|
-
rack-test (~> 0.5.7)
|
24
|
-
tzinfo (~> 0.3.23)
|
25
|
-
activemodel (3.0.5)
|
26
|
-
activesupport (= 3.0.5)
|
27
|
-
builder (~> 2.1.2)
|
28
|
-
i18n (~> 0.4)
|
29
|
-
activerecord (3.0.5)
|
30
|
-
activemodel (= 3.0.5)
|
31
|
-
activesupport (= 3.0.5)
|
32
|
-
arel (~> 2.0.2)
|
33
|
-
tzinfo (~> 0.3.23)
|
34
|
-
activeresource (3.0.5)
|
35
|
-
activemodel (= 3.0.5)
|
36
|
-
activesupport (= 3.0.5)
|
37
|
-
activesupport (3.0.5)
|
38
|
-
arel (2.0.9)
|
39
|
-
bson (1.2.4)
|
40
|
-
bson_ext (1.2.4)
|
41
|
-
builder (2.1.2)
|
42
|
-
erubis (2.6.6)
|
43
|
-
abstract (>= 1.0.0)
|
44
|
-
i18n (0.5.0)
|
45
|
-
mail (2.2.15)
|
46
|
-
activesupport (>= 2.3.6)
|
47
|
-
i18n (>= 0.4.0)
|
48
|
-
mime-types (~> 1.16)
|
49
|
-
treetop (~> 1.4.8)
|
50
|
-
mime-types (1.16)
|
51
|
-
mongo (1.2.4)
|
52
|
-
bson (>= 1.2.4)
|
53
|
-
mongoid (2.0.0.rc.7)
|
54
|
-
activemodel (~> 3.0)
|
55
|
-
mongo (~> 1.2)
|
56
|
-
tzinfo (~> 0.3.22)
|
57
|
-
will_paginate (~> 3.0.pre)
|
58
|
-
polyglot (0.3.1)
|
59
|
-
rack (1.2.2)
|
60
|
-
rack-mount (0.6.14)
|
61
|
-
rack (>= 1.0.0)
|
62
|
-
rack-test (0.5.7)
|
63
|
-
rack (>= 1.0)
|
64
|
-
rails (3.0.5)
|
65
|
-
actionmailer (= 3.0.5)
|
66
|
-
actionpack (= 3.0.5)
|
67
|
-
activerecord (= 3.0.5)
|
68
|
-
activeresource (= 3.0.5)
|
69
|
-
activesupport (= 3.0.5)
|
70
|
-
bundler (~> 1.0)
|
71
|
-
railties (= 3.0.5)
|
72
|
-
railties (3.0.5)
|
73
|
-
actionpack (= 3.0.5)
|
74
|
-
activesupport (= 3.0.5)
|
75
|
-
rake (>= 0.8.7)
|
76
|
-
thor (~> 0.14.4)
|
77
|
-
rake (0.8.7)
|
78
|
-
shoulda (2.11.3)
|
79
|
-
sqlite3 (1.3.3)
|
80
|
-
sqlite3-ruby (1.3.3)
|
81
|
-
sqlite3 (>= 1.3.3)
|
82
|
-
thor (0.14.6)
|
83
|
-
treetop (1.4.9)
|
84
|
-
polyglot (>= 0.3.1)
|
85
|
-
tzinfo (0.3.24)
|
86
|
-
will_paginate (3.0.pre2)
|
87
|
-
yajl-ruby (0.8.2)
|
88
|
-
|
89
|
-
PLATFORMS
|
90
|
-
ruby
|
91
|
-
|
92
|
-
DEPENDENCIES
|
93
|
-
bson_ext (~> 1.2.4)
|
94
|
-
mongoid (>= 2.0.0.rc.7)
|
95
|
-
rails3-jquery-autocomplete!
|
96
|
-
shoulda (~> 2.11.1)
|
97
|
-
sqlite3-ruby
|
data/test/helpers.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Rails3JQueryAutocomplete
|
4
|
-
module Test
|
5
|
-
|
6
|
-
class HelpersTest < ::Test::Unit::TestCase
|
7
|
-
|
8
|
-
assert_structure = lambda do |hash|
|
9
|
-
assert_instance_of(String, hash['label'])
|
10
|
-
assert_instance_of(String, hash['value'])
|
11
|
-
end
|
12
|
-
|
13
|
-
items_exist_assert = lambda do |model|
|
14
|
-
items = Helpers.get_items(:model => model), :term => 'A', :method => 'name')
|
15
|
-
assert(items)
|
16
|
-
assert_equal(3, items.size)
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'with Mongoid support' do
|
20
|
-
|
21
|
-
require 'support/mongoid'
|
22
|
-
|
23
|
-
context 'passing a Mongoid query result' do
|
24
|
-
|
25
|
-
include Rails3JQueryAutocomplete::Mongoid::Test
|
26
|
-
|
27
|
-
should 'parse items to JSON' do
|
28
|
-
response = Helpers.json_for_autocomplete(Game.all, :name)
|
29
|
-
assert_not_nil(response)
|
30
|
-
response.each(&assert_structure)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'looking for items' do
|
35
|
-
|
36
|
-
include Rails3JQueryAutocomplete::Mongoid::Test
|
37
|
-
|
38
|
-
should 'return items' do
|
39
|
-
items_exist_assert.call(Game)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'with ActiveRecord support' do
|
45
|
-
|
46
|
-
require 'support/active_record'
|
47
|
-
|
48
|
-
context 'passing an ActiveRecord query result' do
|
49
|
-
|
50
|
-
include Rails3JQueryAutocomplete::ActiveRecord::Test
|
51
|
-
|
52
|
-
should 'parse items to JSON' do
|
53
|
-
response = Helpers.json_for_autocomplete(Game.all, :name)
|
54
|
-
assert_not_nil(response)
|
55
|
-
response.each(&assert_structure)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'looking for items' do
|
60
|
-
|
61
|
-
include Rails3JQueryAutocomplete::ActiveRecord::Test
|
62
|
-
|
63
|
-
should 'return items' do
|
64
|
-
items_exist_assert.call(Movie)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'converting a symbol to connstant' do
|
70
|
-
should 'return a defined constant' do
|
71
|
-
::MyJustDefinedConstant = Class.new
|
72
|
-
assert_equal(::MyJustDefinedConstant, Helpers.get_object(:my_just_defined_constant))
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'returning one symbol for an implemented adapter' do
|
77
|
-
|
78
|
-
require 'support/active_record'
|
79
|
-
require 'support/mongoid'
|
80
|
-
|
81
|
-
should 'return a symbol for defined interface' do
|
82
|
-
assert_equal(:activerecord, Helpers.get_implementation(::Movie))
|
83
|
-
assert_equal(:mongoid, Helpers.get_implementation(::Game))
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
context 'returning a limit integer number' do
|
88
|
-
|
89
|
-
should 'return default value of 10' do
|
90
|
-
assert_equal(10, Helpers.get_limit({}))
|
91
|
-
end
|
92
|
-
|
93
|
-
should 'return params value' do
|
94
|
-
assert_equal(1, Helpers.get_limit(:limit => 1))
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
context 'returning elements ordering' do
|
99
|
-
|
100
|
-
should 'returning default ascending order for activerecord' do
|
101
|
-
assert_equal("name ASC", Helpers.get_order(:activerecord, 'name', {}))
|
102
|
-
end
|
103
|
-
|
104
|
-
should 'returning descending order for activerecord' do
|
105
|
-
assert_equal("thisfield DESC", Helpers.get_order(:activerecord, 'otherfield', :order => 'thisfield DESC'))
|
106
|
-
end
|
107
|
-
|
108
|
-
should 'returning default ascending order for mongoid' do
|
109
|
-
expected = [[:name, :asc]]
|
110
|
-
returned = Helpers.get_order(:mongoid, 'name', {})
|
111
|
-
assert expected.eql?(returned)
|
112
|
-
end
|
113
|
-
|
114
|
-
should 'returning order according paramters for mongoid' do
|
115
|
-
expected = [[:first, :asc], [:second, :desc]]
|
116
|
-
returned = Helpers.get_order(:mongoid, 'name', {:order => 'first asc, second desc'})
|
117
|
-
assert expected.eql?(returned)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|