globalize3-jquery-autocomplete 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.travis.yml +11 -0
- data/Appraisals +11 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +18 -0
- data/gemfiles/rails_3.0.gemfile +7 -0
- data/gemfiles/rails_3.1.gemfile +7 -0
- data/gemfiles/rails_3.2.gemfile +7 -0
- data/globalize3-jquery-autocomplete.gemspec +31 -0
- data/lib/globalize3-jquery-autocomplete.rb +16 -0
- data/lib/globalize3_jquery_autocomplete/orm/active_record.rb +69 -0
- data/lib/globalize3_jquery_autocomplete/version.rb +3 -0
- data/spec/data/models.rb +7 -0
- data/spec/data/schema.rb +23 -0
- data/spec/orm/active_record_spec.rb +161 -0
- data/spec/spec_helper.rb +42 -0
- metadata +222 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Appraisals
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 emjot GmbH & Co. KG
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# globalize3-jquery-autocomplete
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/emjot/globalize3-jquery-autocomplete)
|
|
4
|
+
|
|
5
|
+
Use JQuery autocomplete (via [rails3-jquery-autocomplete](https://github.com/crowdint/rails3-jquery-autocomplete)) with [globalize3](https://github.com/svenfuchs/globalize3) translated ActiveRecord models.
|
|
6
|
+
|
|
7
|
+
Internals: This gem patches the `get_autocomplete_items` method (provided by rails3-jquery-autocomplete) so it works with translated model columns.
|
|
8
|
+
|
|
9
|
+
## Compatibility
|
|
10
|
+
|
|
11
|
+
rails3-jquery-autocomplete 1.0 and globalize3 0.3 are supported.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
This gem is not yet available via rubygems.
|
|
16
|
+
|
|
17
|
+
Add this line to your application's Gemfile:
|
|
18
|
+
|
|
19
|
+
gem 'globalize3-jquery-autocomplete', :git => 'https://github.com/emjot/globalize3-jquery-autocomplete.git'
|
|
20
|
+
|
|
21
|
+
And then execute:
|
|
22
|
+
|
|
23
|
+
$ bundle
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
Simply follow the documentation at [globalize3](https://github.com/svenfuchs/globalize3) for how to translate your models
|
|
28
|
+
and [rails3-jquery-autocomplete](https://github.com/crowdint/rails3-jquery-autocomplete) for how to set up autocomplete.
|
|
29
|
+
|
|
30
|
+
You don't need any additional configuration. As soon as a column is translated, autocomplete will automatically be in context of the current locale.
|
|
31
|
+
|
|
32
|
+
Example (in your controller):
|
|
33
|
+
|
|
34
|
+
# query for matches in the current locale (given the 'name' column of your Brand model is translated):
|
|
35
|
+
autocomplete :brand, :name
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## Contributing
|
|
39
|
+
|
|
40
|
+
1. Fork it
|
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
44
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'bundler/setup'
|
|
2
|
+
require 'appraisal'
|
|
3
|
+
require 'rspec/core/rake_task'
|
|
4
|
+
|
|
5
|
+
require 'bundler/gem_tasks'
|
|
6
|
+
|
|
7
|
+
desc 'Default: run all tests with all supported Rails versions'
|
|
8
|
+
task :default => :all
|
|
9
|
+
|
|
10
|
+
desc 'Run tests with all supported Rails versions.'
|
|
11
|
+
task :all => ["appraisal:install"] do
|
|
12
|
+
exec('rake appraisal spec')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc 'Run all tests'
|
|
16
|
+
RSpec::Core::RakeTask.new('spec') do |t|
|
|
17
|
+
t.pattern = FileList['spec/**/*_spec.rb']
|
|
18
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'globalize3_jquery_autocomplete/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "globalize3-jquery-autocomplete"
|
|
8
|
+
spec.version = Globalize3JqueryAutocomplete::VERSION
|
|
9
|
+
spec.authors = ["Maximilian Herold"]
|
|
10
|
+
spec.email = ["herold@emjot.de"]
|
|
11
|
+
spec.description = %q{Use jQuery's autocomplete plugin with Rails 3 and globalize3 translated models.}
|
|
12
|
+
spec.summary = %q{Use jQuery's autocomplete plugin with Rails 3 and globalize3 translated models.}
|
|
13
|
+
spec.homepage = "https://github.com/emjot/globalize3-jquery-autocomplete"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_runtime_dependency "rails", "~> 3.0"
|
|
22
|
+
spec.add_runtime_dependency "globalize3", "~> 0.3"
|
|
23
|
+
spec.add_runtime_dependency "rails3-jquery-autocomplete", "~> 1.0"
|
|
24
|
+
|
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
|
26
|
+
spec.add_development_dependency "appraisal", "~> 0.5.1"
|
|
27
|
+
spec.add_development_dependency "rspec-rails", "~> 2.8.0"
|
|
28
|
+
spec.add_development_dependency "database_cleaner", "~> 0.6"
|
|
29
|
+
spec.add_development_dependency "sqlite3"
|
|
30
|
+
spec.add_development_dependency "rake"
|
|
31
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require "globalize3_jquery_autocomplete/version"
|
|
2
|
+
require "globalize3_jquery_autocomplete/orm/active_record"
|
|
3
|
+
|
|
4
|
+
require "rails/all"
|
|
5
|
+
require "globalize3"
|
|
6
|
+
require "rails3-jquery-autocomplete"
|
|
7
|
+
|
|
8
|
+
ActiveSupport.on_load :action_controller do
|
|
9
|
+
if defined?(Mongoid::Document) || defined?(MongoMapper::Document)
|
|
10
|
+
if Rails.logger.try(:error?)
|
|
11
|
+
Rails.logger.error("globalize3-jquery-autocomplete only supports ActiveRecord (not Mongoid / MongoMapper)")
|
|
12
|
+
end
|
|
13
|
+
else
|
|
14
|
+
ActionController::Base.send(:include, Globalize3JQueryAutocomplete::Orm::ActiveRecord)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Patch for rails3-jquery-autocomplete to work with globalize3.
|
|
2
|
+
# (based on rails3-jquery-autocomplete 1.0.11)
|
|
3
|
+
module Globalize3JQueryAutocomplete
|
|
4
|
+
module Orm
|
|
5
|
+
module ActiveRecord
|
|
6
|
+
|
|
7
|
+
def self.included(base)
|
|
8
|
+
base.send :include, InstanceMethods
|
|
9
|
+
base.send :alias_method_chain, :get_autocomplete_items, :globalize3
|
|
10
|
+
base.send :alias_method_chain, :get_autocomplete_select_clause, :globalize3
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module InstanceMethods
|
|
14
|
+
|
|
15
|
+
def get_autocomplete_items_with_globalize3(parameters)
|
|
16
|
+
model = parameters[:model]
|
|
17
|
+
translated_model = find_globalized_column_class_for(model, parameters[:method])
|
|
18
|
+
model_with_method = translated_model || model
|
|
19
|
+
term = parameters[:term]
|
|
20
|
+
method = parameters[:method]
|
|
21
|
+
options = parameters[:options]
|
|
22
|
+
scopes = Array(options[:scopes])
|
|
23
|
+
where = options[:where]
|
|
24
|
+
limit = get_autocomplete_limit(options)
|
|
25
|
+
order = get_autocomplete_order(method, options, model_with_method)
|
|
26
|
+
|
|
27
|
+
items = model.scoped
|
|
28
|
+
|
|
29
|
+
if scopes.present?
|
|
30
|
+
scopes.each { |scope| items = items.send(scope) }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
unless options[:full_model]
|
|
34
|
+
items = items.select(get_autocomplete_select_clause(model, model_with_method, method, options))
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
if translated_model.present?
|
|
38
|
+
items = items.with_translations(Globalize.locale)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
items = items.where(get_autocomplete_where_clause(model_with_method, term, method, options)).
|
|
42
|
+
limit(limit).order(order)
|
|
43
|
+
|
|
44
|
+
items = items.where(where) if where.present?
|
|
45
|
+
|
|
46
|
+
items.all.uniq
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def get_autocomplete_select_clause_with_globalize3(model_with_pk, model_with_method, method, options)
|
|
50
|
+
pk_table_name = model_with_pk.table_name
|
|
51
|
+
m_table_name = model_with_method.table_name
|
|
52
|
+
|
|
53
|
+
(["#{pk_table_name}.#{model_with_pk.primary_key}", "#{m_table_name}.#{method}"] +
|
|
54
|
+
(options[:extra_data].presence || []))
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# If the attribute of the record is globalized, returns the translation class; otherwise, returns nil.
|
|
58
|
+
def find_globalized_column_class_for(record, attribute)
|
|
59
|
+
if record.respond_to?(:translation_class) && record.translated_attribute_names.include?(attribute)
|
|
60
|
+
record.translation_class
|
|
61
|
+
else
|
|
62
|
+
nil
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
data/spec/data/models.rb
ADDED
data/spec/data/schema.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
ActiveRecord::Migration.verbose = false
|
|
2
|
+
|
|
3
|
+
ActiveRecord::Schema.define do
|
|
4
|
+
create_table :posts, :force => true do |t|
|
|
5
|
+
t.string :untranslated
|
|
6
|
+
t.integer :rating
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
create_table :post_translations, :force => true do |t|
|
|
10
|
+
t.string :locale
|
|
11
|
+
t.references :post
|
|
12
|
+
t.string :title
|
|
13
|
+
t.text :content
|
|
14
|
+
t.boolean :published
|
|
15
|
+
t.datetime :published_at
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
create_table :untranslateds, :force => true do |t|
|
|
19
|
+
t.string :name
|
|
20
|
+
t.integer :rating
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe 'Globalize3JQueryAutocomplete::Orm::ActiveRecord' do
|
|
5
|
+
let(:helper) do
|
|
6
|
+
Rails3JQueryAutocomplete::Orm::ActiveRecordTestHelper.new()
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "#get_autocomplete_order" do
|
|
10
|
+
describe 'order is specified' do
|
|
11
|
+
it 'should returns that order option' do
|
|
12
|
+
helper.get_autocomplete_order(:field, {:order => 'field ASC'}).should == "field ASC"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe 'no order is specified' do
|
|
17
|
+
it 'should return the order clause by the field ASC' do
|
|
18
|
+
helper.get_autocomplete_order(:field, {}).should == "field ASC"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe 'a different model is specified' do
|
|
22
|
+
it 'should return the order clause by the table_name.field ASC' do
|
|
23
|
+
model = double("model")
|
|
24
|
+
model.stub(:table_name => 'table_name')
|
|
25
|
+
helper.get_autocomplete_order(:field, {}, model).should == "table_name.field ASC"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe '#get_autocomplete_items' do
|
|
32
|
+
before(:each) do
|
|
33
|
+
# create 'en' posts
|
|
34
|
+
@matching_en_posts = %w(query3 QUERY query2).collect { |title| Post.create!(:title => title, :untranslated => title) }
|
|
35
|
+
other_en_posts = %w(myquery Foo bar).collect { |title| Post.create!(:title => title, :untranslated => title) }
|
|
36
|
+
Globalize.with_locale(:de) do
|
|
37
|
+
# add a 'de' translation to the first 'en' post
|
|
38
|
+
@matching_en_de_posts = [@matching_en_posts.first]
|
|
39
|
+
@matching_en_de_posts.first.update_attributes!(:title => 'query_de')
|
|
40
|
+
|
|
41
|
+
@matching_de_posts = @matching_en_de_posts.dup
|
|
42
|
+
|
|
43
|
+
# create 'de' posts
|
|
44
|
+
@matching_de_posts += %w(queryde QUERYde2).collect { |title| Post.create!(:title => title, :untranslated => title) }
|
|
45
|
+
other_de_posts = %w(myqueryde DE).collect { |title| Post.create!(:title => title, :untranslated => title) }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
@matching_posts = (@matching_de_posts + @matching_en_posts).uniq
|
|
49
|
+
|
|
50
|
+
@options = {
|
|
51
|
+
:model => Post,
|
|
52
|
+
:term => 'query',
|
|
53
|
+
:options => {}
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'should work with an untranslated column (untranslated model)' do
|
|
58
|
+
matching = Untranslated.create!(:name => 'queryme')
|
|
59
|
+
Untranslated.create!(:name => 'foo')
|
|
60
|
+
@options.merge!(:model => Untranslated, :method => :name)
|
|
61
|
+
|
|
62
|
+
helper.get_autocomplete_items(@options).should == [matching]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'should work with an untranslated column (translated model)' do
|
|
66
|
+
@options.merge!(:method => :untranslated)
|
|
67
|
+
helper.get_autocomplete_items(@options).should == @matching_posts.sort_by(&:untranslated)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it 'should work with a translated column' do
|
|
71
|
+
@options.merge!(:method => :title)
|
|
72
|
+
helper.get_autocomplete_items(@options).should == @matching_en_posts.sort_by(&:title)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
describe '#get_autocomplete_select_clause' do
|
|
78
|
+
before(:each) do
|
|
79
|
+
@model = double("model")
|
|
80
|
+
@model.stub(:table_name => 'table_name', :primary_key => 'id')
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'should create a select clause' do
|
|
84
|
+
helper.get_autocomplete_select_clause(@model, @model, :method, {}).should ==
|
|
85
|
+
["table_name.id", "table_name.method"]
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
describe 'with extra options' do
|
|
89
|
+
it 'should return those extra fields on the clause' do
|
|
90
|
+
options = {:extra_data => ['table_name.created_at']}
|
|
91
|
+
|
|
92
|
+
helper.get_autocomplete_select_clause(@model, @model, :method, options).should ==
|
|
93
|
+
["table_name.id", "table_name.method", "table_name.created_at"]
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe '#get_autocomplete_where_clause' do
|
|
99
|
+
before(:each) do
|
|
100
|
+
@model = double("model")
|
|
101
|
+
@model.stub(:table_name => 'table_name')
|
|
102
|
+
|
|
103
|
+
@term = 'query'
|
|
104
|
+
@options = {}
|
|
105
|
+
@method = :method
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
describe 'Not Postgres' do
|
|
109
|
+
it 'should return options for where' do
|
|
110
|
+
helper.stub(:postgres?).with(@model).and_return(false)
|
|
111
|
+
helper.get_autocomplete_where_clause(@model, @term, @method, @options).should ==
|
|
112
|
+
["LOWER(table_name.method) LIKE ?", "query%"]
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
describe 'Postgres' do
|
|
117
|
+
it 'should return options for where with ILIKE' do
|
|
118
|
+
helper.stub(:postgres?).with(@model).and_return(true)
|
|
119
|
+
helper.get_autocomplete_where_clause(@model, @term, @method, @options).should ==
|
|
120
|
+
["LOWER(table_name.method) ILIKE ?", "query%"]
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
describe 'full search' do
|
|
125
|
+
it 'should return options for where with the term sourrounded by %%' do
|
|
126
|
+
helper.stub(:postgres?).with(@model).and_return(false)
|
|
127
|
+
@options[:full] = true
|
|
128
|
+
helper.get_autocomplete_where_clause(@model, @term, @method, @options).should ==
|
|
129
|
+
["LOWER(table_name.method) LIKE ?", "%query%"]
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
describe '#postgres?' do
|
|
135
|
+
before(:each) do
|
|
136
|
+
@model = double("model")
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
describe 'the connection class is not postgres' do
|
|
140
|
+
before(:each) do
|
|
141
|
+
@model.stub(:connection).and_return { double("something") }
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it 'should return nil if the connection class matches PostgreSQLAdapter' do
|
|
145
|
+
helper.postgres?(@model).should be_nil
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
describe 'the connection class matches PostgreSQLAdapter' do
|
|
150
|
+
before(:each) do
|
|
151
|
+
class PostgreSQLAdapter; end
|
|
152
|
+
@model.stub(:connection => PostgreSQLAdapter.new)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it 'should return true' do
|
|
156
|
+
helper.postgres?(@model).should be_true
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/globalize3-jquery-autocomplete'))
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'logger'
|
|
5
|
+
require 'database_cleaner'
|
|
6
|
+
|
|
7
|
+
RSpec.configure do |config|
|
|
8
|
+
|
|
9
|
+
config.mock_with :rspec
|
|
10
|
+
|
|
11
|
+
config.before(:suite) do
|
|
12
|
+
DatabaseCleaner.strategy = :truncation
|
|
13
|
+
|
|
14
|
+
tmpdir = File.join(File.dirname(__FILE__), "../tmp")
|
|
15
|
+
FileUtils.mkdir(tmpdir) unless File.exist?(tmpdir)
|
|
16
|
+
log = File.expand_path(File.join(tmpdir, "globalize3_test.log"))
|
|
17
|
+
FileUtils.touch(log) unless File.exists?(log)
|
|
18
|
+
ActiveRecord::Base.logger = Logger.new(log)
|
|
19
|
+
ActiveRecord::LogSubscriber.attach_to(:active_record)
|
|
20
|
+
|
|
21
|
+
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
|
|
22
|
+
require File.expand_path('../data/schema', __FILE__)
|
|
23
|
+
require File.expand_path('../data/models', __FILE__)
|
|
24
|
+
|
|
25
|
+
I18n.locale = I18n.default_locale = :en
|
|
26
|
+
Globalize.locale = nil
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
config.before(:each) do
|
|
30
|
+
DatabaseCleaner.start
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
config.after(:each) do
|
|
34
|
+
DatabaseCleaner.clean
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class Rails3JQueryAutocomplete::Orm::ActiveRecordTestHelper
|
|
40
|
+
include Rails3JQueryAutocomplete::Autocomplete
|
|
41
|
+
include Globalize3JQueryAutocomplete::Orm::ActiveRecord
|
|
42
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: globalize3-jquery-autocomplete
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 27
|
|
5
|
+
prerelease:
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 1
|
|
9
|
+
- 0
|
|
10
|
+
version: 0.1.0
|
|
11
|
+
platform: ruby
|
|
12
|
+
authors:
|
|
13
|
+
- Maximilian Herold
|
|
14
|
+
autorequire:
|
|
15
|
+
bindir: bin
|
|
16
|
+
cert_chain: []
|
|
17
|
+
|
|
18
|
+
date: 2013-03-27 00:00:00 Z
|
|
19
|
+
dependencies:
|
|
20
|
+
- !ruby/object:Gem::Dependency
|
|
21
|
+
name: rails
|
|
22
|
+
prerelease: false
|
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
+
none: false
|
|
25
|
+
requirements:
|
|
26
|
+
- - ~>
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
hash: 7
|
|
29
|
+
segments:
|
|
30
|
+
- 3
|
|
31
|
+
- 0
|
|
32
|
+
version: "3.0"
|
|
33
|
+
type: :runtime
|
|
34
|
+
version_requirements: *id001
|
|
35
|
+
- !ruby/object:Gem::Dependency
|
|
36
|
+
name: globalize3
|
|
37
|
+
prerelease: false
|
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
39
|
+
none: false
|
|
40
|
+
requirements:
|
|
41
|
+
- - ~>
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
hash: 13
|
|
44
|
+
segments:
|
|
45
|
+
- 0
|
|
46
|
+
- 3
|
|
47
|
+
version: "0.3"
|
|
48
|
+
type: :runtime
|
|
49
|
+
version_requirements: *id002
|
|
50
|
+
- !ruby/object:Gem::Dependency
|
|
51
|
+
name: rails3-jquery-autocomplete
|
|
52
|
+
prerelease: false
|
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
54
|
+
none: false
|
|
55
|
+
requirements:
|
|
56
|
+
- - ~>
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
hash: 15
|
|
59
|
+
segments:
|
|
60
|
+
- 1
|
|
61
|
+
- 0
|
|
62
|
+
version: "1.0"
|
|
63
|
+
type: :runtime
|
|
64
|
+
version_requirements: *id003
|
|
65
|
+
- !ruby/object:Gem::Dependency
|
|
66
|
+
name: bundler
|
|
67
|
+
prerelease: false
|
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
69
|
+
none: false
|
|
70
|
+
requirements:
|
|
71
|
+
- - ~>
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
hash: 9
|
|
74
|
+
segments:
|
|
75
|
+
- 1
|
|
76
|
+
- 3
|
|
77
|
+
version: "1.3"
|
|
78
|
+
type: :development
|
|
79
|
+
version_requirements: *id004
|
|
80
|
+
- !ruby/object:Gem::Dependency
|
|
81
|
+
name: appraisal
|
|
82
|
+
prerelease: false
|
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
84
|
+
none: false
|
|
85
|
+
requirements:
|
|
86
|
+
- - ~>
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
hash: 9
|
|
89
|
+
segments:
|
|
90
|
+
- 0
|
|
91
|
+
- 5
|
|
92
|
+
- 1
|
|
93
|
+
version: 0.5.1
|
|
94
|
+
type: :development
|
|
95
|
+
version_requirements: *id005
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: rspec-rails
|
|
98
|
+
prerelease: false
|
|
99
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
|
100
|
+
none: false
|
|
101
|
+
requirements:
|
|
102
|
+
- - ~>
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
hash: 47
|
|
105
|
+
segments:
|
|
106
|
+
- 2
|
|
107
|
+
- 8
|
|
108
|
+
- 0
|
|
109
|
+
version: 2.8.0
|
|
110
|
+
type: :development
|
|
111
|
+
version_requirements: *id006
|
|
112
|
+
- !ruby/object:Gem::Dependency
|
|
113
|
+
name: database_cleaner
|
|
114
|
+
prerelease: false
|
|
115
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
|
116
|
+
none: false
|
|
117
|
+
requirements:
|
|
118
|
+
- - ~>
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
hash: 7
|
|
121
|
+
segments:
|
|
122
|
+
- 0
|
|
123
|
+
- 6
|
|
124
|
+
version: "0.6"
|
|
125
|
+
type: :development
|
|
126
|
+
version_requirements: *id007
|
|
127
|
+
- !ruby/object:Gem::Dependency
|
|
128
|
+
name: sqlite3
|
|
129
|
+
prerelease: false
|
|
130
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
|
131
|
+
none: false
|
|
132
|
+
requirements:
|
|
133
|
+
- - ">="
|
|
134
|
+
- !ruby/object:Gem::Version
|
|
135
|
+
hash: 3
|
|
136
|
+
segments:
|
|
137
|
+
- 0
|
|
138
|
+
version: "0"
|
|
139
|
+
type: :development
|
|
140
|
+
version_requirements: *id008
|
|
141
|
+
- !ruby/object:Gem::Dependency
|
|
142
|
+
name: rake
|
|
143
|
+
prerelease: false
|
|
144
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
|
145
|
+
none: false
|
|
146
|
+
requirements:
|
|
147
|
+
- - ">="
|
|
148
|
+
- !ruby/object:Gem::Version
|
|
149
|
+
hash: 3
|
|
150
|
+
segments:
|
|
151
|
+
- 0
|
|
152
|
+
version: "0"
|
|
153
|
+
type: :development
|
|
154
|
+
version_requirements: *id009
|
|
155
|
+
description: Use jQuery's autocomplete plugin with Rails 3 and globalize3 translated models.
|
|
156
|
+
email:
|
|
157
|
+
- herold@emjot.de
|
|
158
|
+
executables: []
|
|
159
|
+
|
|
160
|
+
extensions: []
|
|
161
|
+
|
|
162
|
+
extra_rdoc_files: []
|
|
163
|
+
|
|
164
|
+
files:
|
|
165
|
+
- .gitignore
|
|
166
|
+
- .rspec
|
|
167
|
+
- .travis.yml
|
|
168
|
+
- Appraisals
|
|
169
|
+
- Gemfile
|
|
170
|
+
- LICENSE.txt
|
|
171
|
+
- README.md
|
|
172
|
+
- Rakefile
|
|
173
|
+
- gemfiles/rails_3.0.gemfile
|
|
174
|
+
- gemfiles/rails_3.1.gemfile
|
|
175
|
+
- gemfiles/rails_3.2.gemfile
|
|
176
|
+
- globalize3-jquery-autocomplete.gemspec
|
|
177
|
+
- lib/globalize3-jquery-autocomplete.rb
|
|
178
|
+
- lib/globalize3_jquery_autocomplete/orm/active_record.rb
|
|
179
|
+
- lib/globalize3_jquery_autocomplete/version.rb
|
|
180
|
+
- spec/data/models.rb
|
|
181
|
+
- spec/data/schema.rb
|
|
182
|
+
- spec/orm/active_record_spec.rb
|
|
183
|
+
- spec/spec_helper.rb
|
|
184
|
+
homepage: https://github.com/emjot/globalize3-jquery-autocomplete
|
|
185
|
+
licenses:
|
|
186
|
+
- MIT
|
|
187
|
+
post_install_message:
|
|
188
|
+
rdoc_options: []
|
|
189
|
+
|
|
190
|
+
require_paths:
|
|
191
|
+
- lib
|
|
192
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
193
|
+
none: false
|
|
194
|
+
requirements:
|
|
195
|
+
- - ">="
|
|
196
|
+
- !ruby/object:Gem::Version
|
|
197
|
+
hash: 3
|
|
198
|
+
segments:
|
|
199
|
+
- 0
|
|
200
|
+
version: "0"
|
|
201
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
|
+
none: false
|
|
203
|
+
requirements:
|
|
204
|
+
- - ">="
|
|
205
|
+
- !ruby/object:Gem::Version
|
|
206
|
+
hash: 3
|
|
207
|
+
segments:
|
|
208
|
+
- 0
|
|
209
|
+
version: "0"
|
|
210
|
+
requirements: []
|
|
211
|
+
|
|
212
|
+
rubyforge_project:
|
|
213
|
+
rubygems_version: 1.8.15
|
|
214
|
+
signing_key:
|
|
215
|
+
specification_version: 3
|
|
216
|
+
summary: Use jQuery's autocomplete plugin with Rails 3 and globalize3 translated models.
|
|
217
|
+
test_files:
|
|
218
|
+
- spec/data/models.rb
|
|
219
|
+
- spec/data/schema.rb
|
|
220
|
+
- spec/orm/active_record_spec.rb
|
|
221
|
+
- spec/spec_helper.rb
|
|
222
|
+
has_rdoc:
|