repeated_auto_complete 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/auto_complete_macros_helper.rb +2 -2
- data/lib/view_mapper/has_many_auto_complete_view.rb +1 -1
- data/repeated_auto_complete.gemspec +2 -2
- data/test/auto_complete_form_builder_helper_test.rb +1 -1
- data/test/auto_complete_nested_attributes_test.rb +1 -1
- data/test/auto_complete_test.rb +6 -3
- data/test/view_mapper/has_many_auto_complete_view_test.rb +20 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -96,9 +96,9 @@ module AutoCompleteMacrosHelper
|
|
96
96
|
#
|
97
97
|
# The auto_complete_result can of course also be called from a view belonging to the
|
98
98
|
# auto_complete action if you need to decorate it further.
|
99
|
-
def auto_complete_result(entries,
|
99
|
+
def auto_complete_result(entries, method, phrase = nil)
|
100
100
|
return unless entries
|
101
|
-
items = entries.map { |entry| content_tag("li", phrase ? highlight(entry
|
101
|
+
items = entries.map { |entry| content_tag("li", phrase ? highlight(entry.send(method), phrase) : h(entry.send(method))) }
|
102
102
|
content_tag("ul", items.uniq.join)
|
103
103
|
end
|
104
104
|
|
@@ -63,7 +63,7 @@ module ViewMapper
|
|
63
63
|
|
64
64
|
def auto_complete_attributes_for_model(model_info)
|
65
65
|
model_info.text_fields.collect do |text_field|
|
66
|
-
{ :model_name => model_info.name.
|
66
|
+
{ :model_name => model_info.name.underscore, :text_field => text_field }
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{repeated_auto_complete}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Pat Shaughnessy"]
|
12
|
-
s.date = %q{2010-02
|
12
|
+
s.date = %q{2010-03-02}
|
13
13
|
s.description = %q{auto_complete plugin refactored to handle complex forms and named scopes}
|
14
14
|
s.email = %q{pat@patshaughnessy.net}
|
15
15
|
s.extra_rdoc_files = [
|
data/test/auto_complete_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'helper'
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
2
|
|
3
3
|
ActionController::Routing::Routes.draw do |map|
|
4
4
|
map.connect ':controller/:action/:id'
|
@@ -40,6 +40,9 @@ class AutoCompleteTest < ActionController::TestCase
|
|
40
40
|
end
|
41
41
|
@controller = @controller.new
|
42
42
|
|
43
|
+
ActiveRecord::Base.connection.create_table :some_models, :force => true do |table|
|
44
|
+
table.column :title, :string
|
45
|
+
end
|
43
46
|
Object.const_set("SomeModel", Class.new(ActiveRecord::Base)) unless Object.const_defined?("SomeModel")
|
44
47
|
|
45
48
|
@request = ActionController::TestRequest.new
|
@@ -71,13 +74,13 @@ class AutoCompleteTest < ActionController::TestCase
|
|
71
74
|
end
|
72
75
|
|
73
76
|
def test_auto_complete_result
|
74
|
-
result = [
|
77
|
+
result = [ SomeModel.new(:title => 'test1'), SomeModel.new(:title => 'test2') ]
|
75
78
|
assert_equal %(<ul><li>test1</li><li>test2</li></ul>),
|
76
79
|
auto_complete_result(result, :title)
|
77
80
|
assert_equal %(<ul><li>t<strong class=\"highlight\">est</strong>1</li><li>t<strong class=\"highlight\">est</strong>2</li></ul>),
|
78
81
|
auto_complete_result(result, :title, "est")
|
79
82
|
|
80
|
-
resultuniq = [
|
83
|
+
resultuniq = [ SomeModel.new(:title => 'test1'), SomeModel.new(:title => 'test1') ]
|
81
84
|
assert_equal %(<ul><li>t<strong class=\"highlight\">est</strong>1</li></ul>),
|
82
85
|
auto_complete_result(resultuniq, :title, "est")
|
83
86
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'helper'
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../helper')
|
2
2
|
require 'shoulda'
|
3
3
|
require 'mocha'
|
4
4
|
require 'rails_generator'
|
@@ -314,6 +314,25 @@ class HasManyAutoCompleteViewTest < Test::Unit::TestCase
|
|
314
314
|
end
|
315
315
|
end
|
316
316
|
|
317
|
+
|
318
|
+
context "A view_for generator instantiated for a test model with a camel case name" do
|
319
|
+
setup do
|
320
|
+
setup_test_model
|
321
|
+
setup_parent_test_model
|
322
|
+
SomeOtherModel.class_eval do
|
323
|
+
has_many :testies
|
324
|
+
end
|
325
|
+
stub_warnings
|
326
|
+
@gen = new_generator_for_test_model('view_for', ['--view', 'has_many_auto_complete'], 'some_other_model')
|
327
|
+
end
|
328
|
+
|
329
|
+
should "find the text field attributes" do
|
330
|
+
assert_equal [
|
331
|
+
{:model_name=>"some_other_model", :text_field=>"name" }
|
332
|
+
], @gen.find_auto_complete_attributes
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
317
336
|
context "A Rails generator script" do
|
318
337
|
setup do
|
319
338
|
setup_test_model
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repeated_auto_complete
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Shaughnessy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02
|
12
|
+
date: 2010-03-02 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|