rails3-jquery-autocomplete 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +3 -0
- data/integration/app/controllers/scoped_autocompletes_controller.rb +1 -1
- data/integration/app/models/address.rb +2 -0
- data/integration/app/models/brand.rb +3 -0
- data/integration/db/migrate/20110512153732_create_addresses.rb +13 -0
- data/integration/db/migrate/20110512153811_add_address_id_to_brand.rb +9 -0
- data/integration/db/schema.rb +8 -1
- data/integration/features/autocomplete.feature +6 -5
- data/integration/features/step_definitions/autocomplete_steps.rb +5 -0
- data/lib/rails3-jquery-autocomplete/helpers.rb +7 -6
- data/lib/rails3-jquery-autocomplete/version.rb +1 -1
- metadata +7 -4
data/README.markdown
CHANGED
@@ -272,10 +272,13 @@ You can run the integration tests with the cucumber command while on the
|
|
272
272
|
integration folder:
|
273
273
|
|
274
274
|
cd integration
|
275
|
+
rake db:migrate
|
275
276
|
cucumber
|
276
277
|
|
277
278
|
# Changelog
|
278
279
|
|
280
|
+
* 0.7.1 Fixed joined scopes (Issue #43)
|
281
|
+
* 0.7.0 Scopes
|
279
282
|
* 0.6.6 ILIKE for postgres
|
280
283
|
* 0.6.5 JS select event
|
281
284
|
* 0.6.4 Use YAJL instead of JSON
|
data/integration/db/schema.rb
CHANGED
@@ -10,7 +10,13 @@
|
|
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 => 20110512153811) do
|
14
|
+
|
15
|
+
create_table "addresses", :force => true do |t|
|
16
|
+
t.string "street"
|
17
|
+
t.datetime "created_at"
|
18
|
+
t.datetime "updated_at"
|
19
|
+
end
|
14
20
|
|
15
21
|
create_table "brands", :force => true do |t|
|
16
22
|
t.string "name"
|
@@ -18,6 +24,7 @@ ActiveRecord::Schema.define(:version => 20110423000347) do
|
|
18
24
|
t.datetime "updated_at"
|
19
25
|
t.string "type"
|
20
26
|
t.boolean "state"
|
27
|
+
t.integer "address_id"
|
21
28
|
end
|
22
29
|
|
23
30
|
create_table "features", :force => true do |t|
|
@@ -6,11 +6,11 @@ Feature: Autocomplete
|
|
6
6
|
Background:
|
7
7
|
Given the following brands exists:
|
8
8
|
| name | state |
|
9
|
-
| Alpha |
|
10
|
-
| Beta |
|
11
|
-
| Gamma |
|
12
|
-
| Kappa |
|
13
|
-
| Kappler |
|
9
|
+
| Alpha | true |
|
10
|
+
| Beta | false |
|
11
|
+
| Gamma | false |
|
12
|
+
| Kappa | true |
|
13
|
+
| Kappler | false |
|
14
14
|
And the following features exists:
|
15
15
|
| name |
|
16
16
|
| Shiny |
|
@@ -66,6 +66,7 @@ Feature: Autocomplete
|
|
66
66
|
|
67
67
|
@javascript
|
68
68
|
Scenario: Autocomplete with scope
|
69
|
+
Given the "Kappa" brand has an address
|
69
70
|
Given I go to the new scoped autocomplete page
|
70
71
|
And I fill in "Brand name" with "ka"
|
71
72
|
And I choose "Kappa" in the autocomplete list
|
@@ -89,10 +89,10 @@ 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
|
-
term
|
94
|
-
method
|
95
|
-
options
|
92
|
+
model = parameters[:model]
|
93
|
+
term = parameters[:term]
|
94
|
+
method = parameters[:method]
|
95
|
+
options = parameters[:options]
|
96
96
|
|
97
97
|
is_full_search = options[:full]
|
98
98
|
scopes = Array(options[:scopes])
|
@@ -111,8 +111,9 @@ module Rails3JQueryAutocomplete
|
|
111
111
|
search = (is_full_search ? '.*' : '^') + term + '.*'
|
112
112
|
items = model.where(method.to_sym => /#{search}/i).limit(limit).order_by(order)
|
113
113
|
when :activerecord
|
114
|
-
|
115
|
-
items = items.
|
114
|
+
table_name = model.table_name
|
115
|
+
items = items.select(["#{table_name}.id", "#{table_name}.#{method}"] + (options[:extra_data].blank? ? [] : options[:extra_data])) unless options[:full_model]
|
116
|
+
items = items.where(["LOWER(#{table_name}.#{method}) #{like_clause} ?", "#{(is_full_search ? '%' : '')}#{term.downcase}%"]) \
|
116
117
|
.limit(limit).order(order)
|
117
118
|
end
|
118
119
|
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: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 1
|
10
|
+
version: 0.7.1
|
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-
|
18
|
+
date: 2011-05-12 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- integration/app/helpers/id_elements_helper.rb
|
145
145
|
- integration/app/helpers/layout_helper.rb
|
146
146
|
- integration/app/helpers/sub_classes_helper.rb
|
147
|
+
- integration/app/models/address.rb
|
147
148
|
- integration/app/models/brand.rb
|
148
149
|
- integration/app/models/feature.rb
|
149
150
|
- integration/app/models/foreign_brand.rb
|
@@ -177,6 +178,8 @@ files:
|
|
177
178
|
- integration/db/migrate/20101209053936_add_type_to_brand.rb
|
178
179
|
- integration/db/migrate/20110209020136_create_features.rb
|
179
180
|
- integration/db/migrate/20110423000347_add_state_to_brands.rb
|
181
|
+
- integration/db/migrate/20110512153732_create_addresses.rb
|
182
|
+
- integration/db/migrate/20110512153811_add_address_id_to_brand.rb
|
180
183
|
- integration/db/schema.rb
|
181
184
|
- integration/db/seeds.rb
|
182
185
|
- integration/doc/README_FOR_APP
|