rails3-jquery-autocomplete 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/.document +5 -0
  2. data/.gitignore +24 -0
  3. data/Gemfile +18 -0
  4. data/Gemfile.lock +96 -0
  5. data/README.markdown +16 -1
  6. data/Rakefile +2 -47
  7. data/integration/.gitignore +2 -0
  8. data/integration/Gemfile +14 -0
  9. data/integration/Gemfile.lock +159 -0
  10. data/integration/README +256 -0
  11. data/integration/Rakefile +7 -0
  12. data/integration/app/controllers/application_controller.rb +3 -0
  13. data/integration/app/controllers/autocomplete_controller.rb +7 -0
  14. data/integration/app/controllers/id_elements_controller.rb +8 -0
  15. data/integration/app/controllers/multiple_selections_controller.rb +7 -0
  16. data/integration/app/controllers/sub_classes_controller.rb +7 -0
  17. data/integration/app/helpers/application_helper.rb +2 -0
  18. data/integration/app/helpers/autocomplete_helper.rb +2 -0
  19. data/integration/app/helpers/error_messages_helper.rb +23 -0
  20. data/integration/app/helpers/id_elements_helper.rb +2 -0
  21. data/integration/app/helpers/layout_helper.rb +22 -0
  22. data/integration/app/helpers/sub_classes_helper.rb +2 -0
  23. data/integration/app/models/brand.rb +2 -0
  24. data/integration/app/models/foreign_brand.rb +3 -0
  25. data/integration/app/models/product.rb +3 -0
  26. data/integration/app/views/autocomplete/new.html.haml +10 -0
  27. data/integration/app/views/id_elements/new.html.haml +12 -0
  28. data/integration/app/views/layouts/application.html.haml +21 -0
  29. data/integration/app/views/multiple_selections/new.html.haml +9 -0
  30. data/integration/app/views/sub_classes/new.html.haml +9 -0
  31. data/integration/config.ru +4 -0
  32. data/integration/config/application.rb +42 -0
  33. data/integration/config/boot.rb +13 -0
  34. data/integration/config/cucumber.yml +8 -0
  35. data/integration/config/database.yml +25 -0
  36. data/integration/config/environment.rb +5 -0
  37. data/integration/config/environments/development.rb +26 -0
  38. data/integration/config/environments/production.rb +49 -0
  39. data/integration/config/environments/test.rb +35 -0
  40. data/integration/config/initializers/backtrace_silencers.rb +7 -0
  41. data/integration/config/initializers/inflections.rb +10 -0
  42. data/integration/config/initializers/mime_types.rb +5 -0
  43. data/integration/config/initializers/secret_token.rb +7 -0
  44. data/integration/config/initializers/session_store.rb +8 -0
  45. data/integration/config/locales/en.yml +5 -0
  46. data/integration/config/routes.rb +18 -0
  47. data/integration/db/migrate/20101209014338_create_brands.rb +13 -0
  48. data/integration/db/migrate/20101209014355_create_products.rb +14 -0
  49. data/integration/db/migrate/20101209053936_add_type_to_brand.rb +9 -0
  50. data/integration/db/schema.rb +29 -0
  51. data/integration/db/seeds.rb +3 -0
  52. data/integration/doc/README_FOR_APP +2 -0
  53. data/integration/features/autocomplete.feature +45 -0
  54. data/integration/features/step_definitions/autocomplete_steps.rb +5 -0
  55. data/integration/features/step_definitions/pickle_steps.rb +100 -0
  56. data/integration/features/step_definitions/web_steps.rb +219 -0
  57. data/integration/features/support/env.rb +62 -0
  58. data/integration/features/support/paths.rb +33 -0
  59. data/integration/features/support/pickle.rb +24 -0
  60. data/integration/lib/tasks/cucumber.rake +53 -0
  61. data/integration/public/404.html +26 -0
  62. data/integration/public/422.html +26 -0
  63. data/integration/public/500.html +26 -0
  64. data/integration/public/favicon.ico +0 -0
  65. data/integration/public/images/rails.png +0 -0
  66. data/integration/public/javascripts/application.js +0 -0
  67. data/integration/public/javascripts/autocomplete-rails.js +91 -0
  68. data/integration/public/javascripts/jquery-ui.js +11437 -0
  69. data/integration/public/javascripts/jquery-ui.min.js +401 -0
  70. data/integration/public/javascripts/jquery.js +7179 -0
  71. data/integration/public/javascripts/jquery.min.js +167 -0
  72. data/integration/public/javascripts/rails.js +163 -0
  73. data/integration/public/robots.txt +5 -0
  74. data/integration/public/stylesheets/application.css +61 -0
  75. data/integration/public/stylesheets/jquery-ui-1.8.2.custom.css +489 -0
  76. data/integration/public/stylesheets/sass/application.sass +66 -0
  77. data/integration/script/cucumber +10 -0
  78. data/integration/script/rails +6 -0
  79. data/lib/generators/templates/autocomplete-rails.js +1 -1
  80. data/lib/rails3-jquery-autocomplete/autocomplete.rb +3 -1
  81. data/lib/rails3-jquery-autocomplete/version.rb +3 -0
  82. data/rails3-jquery-autocomplete.gemspec +28 -0
  83. metadata +165 -12
@@ -0,0 +1,7 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rake'
6
+
7
+ Integration::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,7 @@
1
+ class AutocompleteController < ApplicationController
2
+ autocomplete :brand, :name
3
+
4
+ def new
5
+ @product = Product.new
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ class IdElementsController < ApplicationController
2
+ autocomplete :brand, :name
3
+
4
+ def new
5
+ @product = Product.new
6
+ end
7
+
8
+ end
@@ -0,0 +1,7 @@
1
+ class MultipleSelectionsController < ApplicationController
2
+ autocomplete :brand, :name
3
+
4
+ def new
5
+ @product = Product.new
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class SubClassesController < ApplicationController
2
+ autocomplete :foreign_brand, :name
3
+
4
+ def new
5
+ @product = Product.new
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module AutocompleteHelper
2
+ end
@@ -0,0 +1,23 @@
1
+ module ErrorMessagesHelper
2
+ # Render error messages for the given objects. The :message and :header_message options are allowed.
3
+ def error_messages_for(*objects)
4
+ options = objects.extract_options!
5
+ options[:header_message] ||= "Invalid Fields"
6
+ options[:message] ||= "Correct the following errors and try again."
7
+ messages = objects.compact.map { |o| o.errors.full_messages }.flatten
8
+ unless messages.empty?
9
+ content_tag(:div, :class => "error_messages") do
10
+ list_items = messages.map { |msg| content_tag(:li, msg) }
11
+ content_tag(:h2, options[:header_message]) + content_tag(:p, options[:message]) + content_tag(:ul, list_items.join.html_safe)
12
+ end
13
+ end
14
+ end
15
+
16
+ module FormBuilderAdditions
17
+ def error_messages(options = {})
18
+ @template.error_messages_for(@object, options)
19
+ end
20
+ end
21
+ end
22
+
23
+ ActionView::Helpers::FormBuilder.send(:include, ErrorMessagesHelper::FormBuilderAdditions)
@@ -0,0 +1,2 @@
1
+ module IdElementsHelper
2
+ end
@@ -0,0 +1,22 @@
1
+ # These helper methods can be called in your template to set variables to be used in the layout
2
+ # This module should be included in all views globally,
3
+ # to do so you may need to add this line to your ApplicationController
4
+ # helper :layout
5
+ module LayoutHelper
6
+ def title(page_title, show_title = true)
7
+ content_for(:title) { h(page_title.to_s) }
8
+ @show_title = show_title
9
+ end
10
+
11
+ def show_title?
12
+ @show_title
13
+ end
14
+
15
+ def stylesheet(*args)
16
+ content_for(:head) { stylesheet_link_tag(*args) }
17
+ end
18
+
19
+ def javascript(*args)
20
+ content_for(:head) { javascript_include_tag(*args) }
21
+ end
22
+ end
@@ -0,0 +1,2 @@
1
+ module SubClassesHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class Brand < ActiveRecord::Base
2
+ end
@@ -0,0 +1,3 @@
1
+ class ForeignBrand < Brand
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class Product < ActiveRecord::Base
2
+ attr_accessor :brand_id
3
+ end
@@ -0,0 +1,10 @@
1
+ %h1 Autocomplete
2
+
3
+ = form_for @product do |form|
4
+ %p
5
+ = form.label :name
6
+ = form.text_field :name
7
+ %p
8
+ = form.label :brand_name
9
+ = form.autocomplete_field :brand_name, autocomplete_autocomplete_brand_name_path
10
+
@@ -0,0 +1,12 @@
1
+ %h1 Id Element
2
+
3
+ = form_for @product do |form|
4
+ %p
5
+ = form.label :name
6
+ = form.text_field :name
7
+ %p
8
+ = form.label :brand_name
9
+ = form.autocomplete_field :brand_name, autocomplete_brand_name_id_elements_path, :id_element => '#product_brand_id'
10
+ %p
11
+ = form.label :brand_id
12
+ = form.text_field :brand_id
@@ -0,0 +1,21 @@
1
+ !!!
2
+ %html
3
+
4
+ %head
5
+ %title
6
+ = yield(:title) || "Untitled"
7
+ %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
8
+ = stylesheet_link_tag "application", 'jquery-ui-1.8.2.custom'
9
+ = javascript_include_tag 'jquery', 'jquery-ui', 'rails', 'autocomplete-rails'
10
+ = csrf_meta_tag
11
+ = yield(:head)
12
+
13
+ %body
14
+ #container
15
+ - flash.each do |name, msg|
16
+ = content_tag :div, msg, :id => "flash_#{name}"
17
+
18
+ - if show_title?
19
+ %h1= yield(:title)
20
+
21
+ = yield
@@ -0,0 +1,9 @@
1
+ %h1 Multiple
2
+
3
+ = form_for @product do |form|
4
+ %p
5
+ = form.label :name
6
+ = form.text_field :name
7
+ %p
8
+ = form.label :brand_name
9
+ = form.autocomplete_field :brand_name, autocomplete_brand_name_multiple_selections_path, :"data-delimiter" => ','
@@ -0,0 +1,9 @@
1
+ %h1 Subclasses
2
+
3
+ = form_for @product do |form|
4
+ %p
5
+ = form.label :name
6
+ = form.text_field :name
7
+ %p
8
+ = form.label :brand_name
9
+ = form.autocomplete_field :brand_name, autocomplete_foreign_brand_name_sub_classes_path
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Integration::Application
@@ -0,0 +1,42 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # If you have a Gemfile, require the gems listed there, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(:default, Rails.env) if defined?(Bundler)
8
+
9
+ module Integration
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ # Custom directories with classes and modules you want to be autoloadable.
16
+ # config.autoload_paths += %W(#{config.root}/extras)
17
+
18
+ # Only load the plugins named here, in the order given (default is alphabetical).
19
+ # :all can be used as a placeholder for all plugins not explicitly named.
20
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
21
+
22
+ # Activate observers that should always be running.
23
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
24
+
25
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
26
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
27
+ # config.time_zone = 'Central Time (US & Canada)'
28
+
29
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
30
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
31
+ # config.i18n.default_locale = :de
32
+
33
+ # JavaScript files you want as :defaults (application.js is always included).
34
+ config.action_view.javascript_expansions[:defaults] = %w()
35
+
36
+ # Configure the default encoding used in templates for Ruby 1.9.
37
+ config.encoding = "utf-8"
38
+
39
+ # Configure sensitive parameters which will be filtered from the log file.
40
+ config.filter_parameters += [:password]
41
+ end
42
+ end
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ gemfile = File.expand_path('../../Gemfile', __FILE__)
5
+ begin
6
+ ENV['BUNDLE_GEMFILE'] = gemfile
7
+ require 'bundler'
8
+ Bundler.setup
9
+ rescue Bundler::GemNotFound => e
10
+ STDERR.puts e.message
11
+ STDERR.puts "Try running `bundle install`."
12
+ exit!
13
+ end if File.exist?(gemfile)
@@ -0,0 +1,8 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> features
7
+ wip: --tags @wip:3 --wip features
8
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test: &test
13
+ adapter: sqlite3
14
+ database: db/test.sqlite3
15
+ pool: 5
16
+ timeout: 5000
17
+
18
+ production:
19
+ adapter: sqlite3
20
+ database: db/production.sqlite3
21
+ pool: 5
22
+ timeout: 5000
23
+
24
+ cucumber:
25
+ <<: *test
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Integration::Application.initialize!
@@ -0,0 +1,26 @@
1
+ Integration::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the webserver when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_view.debug_rjs = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send
18
+ config.action_mailer.raise_delivery_errors = false
19
+
20
+ # Print deprecation notices to the Rails logger
21
+ config.active_support.deprecation = :log
22
+
23
+ # Only use best-standards-support built into browsers
24
+ config.action_dispatch.best_standards_support = :builtin
25
+ end
26
+
@@ -0,0 +1,49 @@
1
+ Integration::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
7
+
8
+ # Full error reports are disabled and caching is turned on
9
+ config.consider_all_requests_local = false
10
+ config.action_controller.perform_caching = true
11
+
12
+ # Specifies the header that your server uses for sending files
13
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
14
+
15
+ # For nginx:
16
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
+
18
+ # If you have no front-end server that supports something like X-Sendfile,
19
+ # just comment this out and Rails will serve the files
20
+
21
+ # See everything in the log (default is :info)
22
+ # config.log_level = :debug
23
+
24
+ # Use a different logger for distributed setups
25
+ # config.logger = SyslogLogger.new
26
+
27
+ # Use a different cache store in production
28
+ # config.cache_store = :mem_cache_store
29
+
30
+ # Disable Rails's static asset server
31
+ # In production, Apache or nginx will already do this
32
+ config.serve_static_assets = false
33
+
34
+ # Enable serving of images, stylesheets, and javascripts from an asset server
35
+ # config.action_controller.asset_host = "http://assets.example.com"
36
+
37
+ # Disable delivery errors, bad email addresses will be ignored
38
+ # config.action_mailer.raise_delivery_errors = false
39
+
40
+ # Enable threaded mode
41
+ # config.threadsafe!
42
+
43
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
44
+ # the I18n.default_locale when a translation can not be found)
45
+ config.i18n.fallbacks = true
46
+
47
+ # Send deprecation notices to registered listeners
48
+ config.active_support.deprecation = :notify
49
+ end
@@ -0,0 +1,35 @@
1
+ Integration::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Raise exceptions instead of rendering exception templates
18
+ config.action_dispatch.show_exceptions = false
19
+
20
+ # Disable request forgery protection in test environment
21
+ config.action_controller.allow_forgery_protection = false
22
+
23
+ # Tell Action Mailer not to deliver emails to the real world.
24
+ # The :test delivery method accumulates sent emails in the
25
+ # ActionMailer::Base.deliveries array.
26
+ config.action_mailer.delivery_method = :test
27
+
28
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
29
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
30
+ # like if you have constraints or database-specific column types
31
+ # config.active_record.schema_format = :sql
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone