Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[rails2 fixture] Adds rails 2 integration tests

  • Loading branch information...
commit 7a26cd9fdce480f3f1f478e663063d76b8f8656f 1 parent 8fd2ffb
Nathan Esquenazi nesquena authored
Showing with 11,272 additions and 0 deletions.
  1. +7 −0 fixtures/rails2/Gemfile
  2. +15 −0 fixtures/rails2/Rakefile
  3. +10 −0 fixtures/rails2/app/controllers/application_controller.rb
  4. +15 −0 fixtures/rails2/app/controllers/posts_controller.rb
  5. +15 −0 fixtures/rails2/app/controllers/users_controller.rb
  6. +7 −0 fixtures/rails2/app/models/phone_number.rb
  7. +3 −0  fixtures/rails2/app/models/post.rb
  8. +3 −0  fixtures/rails2/app/models/user.rb
  9. +6 −0 fixtures/rails2/app/views/layouts/application.html.erb
  10. +3 −0  fixtures/rails2/app/views/posts/date.json.rabl
  11. +11 −0 fixtures/rails2/app/views/posts/index.json.rabl
  12. +16 −0 fixtures/rails2/app/views/posts/show.json.rabl
  13. +3 −0  fixtures/rails2/app/views/users/index.rabl
  14. +6 −0 fixtures/rails2/app/views/users/phone_number.rabl
  15. +16 −0 fixtures/rails2/app/views/users/show.rabl
  16. +129 −0 fixtures/rails2/config/boot.rb
  17. +16 −0 fixtures/rails2/config/database.yml
  18. +42 −0 fixtures/rails2/config/environment.rb
  19. +17 −0 fixtures/rails2/config/environments/development.rb
  20. +28 −0 fixtures/rails2/config/environments/production.rb
  21. +28 −0 fixtures/rails2/config/environments/test.rb
  22. +7 −0 fixtures/rails2/config/initializers/backtrace_silencers.rb
  23. +7 −0 fixtures/rails2/config/initializers/cookie_verification_secret.rb
  24. +10 −0 fixtures/rails2/config/initializers/inflections.rb
  25. +5 −0 fixtures/rails2/config/initializers/mime_types.rb
  26. +21 −0 fixtures/rails2/config/initializers/new_rails_defaults.rb
  27. +6 −0 fixtures/rails2/config/initializers/rabl_loader.rb
  28. +15 −0 fixtures/rails2/config/initializers/session_store.rb
  29. +5 −0 fixtures/rails2/config/locales/en.yml
  30. +20 −0 fixtures/rails2/config/preinitializer.rb
  31. +45 −0 fixtures/rails2/config/routes.rb
  32. +14 −0 fixtures/rails2/db/migrate/20111002075037_create_posts.rb
  33. +15 −0 fixtures/rails2/db/migrate/20111002075053_create_users.rb
  34. +16 −0 fixtures/rails2/db/migrate/20111002075112_create_phone_numbers.rb
  35. +40 −0 fixtures/rails2/db/schema.rb
  36. +7 −0 fixtures/rails2/db/seeds.rb
  37. +2 −0  fixtures/rails2/doc/README_FOR_APP
  38. +2,151 −0 fixtures/rails2/log/database.log
  39. +84 −0 fixtures/rails2/log/development.log
  40. 0  fixtures/rails2/log/production.log
  41. 0  fixtures/rails2/log/server.log
  42. +327 −0 fixtures/rails2/log/test.log
  43. +30 −0 fixtures/rails2/public/404.html
  44. +30 −0 fixtures/rails2/public/422.html
  45. +30 −0 fixtures/rails2/public/500.html
  46. 0  fixtures/rails2/public/favicon.ico
  47. BIN  fixtures/rails2/public/images/rails.png
  48. +275 −0 fixtures/rails2/public/index.html
  49. +2 −0  fixtures/rails2/public/javascripts/application.js
  50. +963 −0 fixtures/rails2/public/javascripts/controls.js
  51. +973 −0 fixtures/rails2/public/javascripts/dragdrop.js
  52. +1,128 −0 fixtures/rails2/public/javascripts/effects.js
  53. +4,320 −0 fixtures/rails2/public/javascripts/prototype.js
  54. +5 −0 fixtures/rails2/public/robots.txt
  55. +4 −0 fixtures/rails2/script/about
  56. +3 −0  fixtures/rails2/script/console
  57. +3 −0  fixtures/rails2/script/dbconsole
  58. +3 −0  fixtures/rails2/script/destroy
  59. +3 −0  fixtures/rails2/script/generate
  60. +3 −0  fixtures/rails2/script/performance/benchmarker
  61. +3 −0  fixtures/rails2/script/performance/profiler
  62. +3 −0  fixtures/rails2/script/plugin
  63. +3 −0  fixtures/rails2/script/runner
  64. +3 −0  fixtures/rails2/script/server
  65. +11 −0 fixtures/rails2/test/fixtures/phone_numbers.yml
  66. +11 −0 fixtures/rails2/test/fixtures/posts.yml
  67. +11 −0 fixtures/rails2/test/fixtures/users.yml
  68. +108 −0 fixtures/rails2/test/functionals/posts_controller_test.rb
  69. +87 −0 fixtures/rails2/test/functionals/users_controller_test.rb
  70. +9 −0 fixtures/rails2/test/performance/browsing_test.rb
  71. +47 −0 fixtures/rails2/test/test_helper.rb
  72. +4 −0 fixtures/rails2/test/unit/helpers/posts_helper_test.rb
  73. +4 −0 fixtures/rails2/test/unit/helpers/users_helper_test.rb
7 fixtures/rails2/Gemfile
View
@@ -0,0 +1,7 @@
+source :gemcutter
+gem "rails", "~> 2.3.14"
+gem "sqlite3-ruby", :require => "sqlite3"
+gem 'rabl', :path => File.expand_path(File.dirname(__FILE__) + "/../../")
+
+gem 'riot', :group => "test"
+gem 'rack-test', :require => "rack/test", :group => "test"
15 fixtures/rails2/Rakefile
View
@@ -0,0 +1,15 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require(File.join(File.dirname(__FILE__), 'config', 'boot'))
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+require 'tasks/rails'
+
+Rake::TestTask.new("test:rabl") do |test|
+ test.pattern = "test/functionals/**/*_test.rb"
+ test.verbose = true
+end
10 fixtures/rails2/app/controllers/application_controller.rb
View
@@ -0,0 +1,10 @@
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+ helper :all # include all helpers, all the time
+ protect_from_forgery # See ActionController::RequestForgeryProtection for details
+
+ # Scrub sensitive parameters from your log
+ # filter_parameter_logging :password
+end
15 fixtures/rails2/app/controllers/posts_controller.rb
View
@@ -0,0 +1,15 @@
+class PostsController < ApplicationController
+ def index
+ @posts = Post.all(:order => "id ASC")
+ respond_to do |format|
+ format.json { render "posts/index" }
+ end
+ end
+
+ def show
+ @post = Post.find(params[:id])
+ respond_to do |format|
+ format.json { render "posts/show" }
+ end
+ end
+end
15 fixtures/rails2/app/controllers/users_controller.rb
View
@@ -0,0 +1,15 @@
+class UsersController < ApplicationController
+ def index
+ @users = User.all(:order => "username ASC")
+ respond_to do |format|
+ format.json { render "users/index" }
+ end
+ end
+
+ def show
+ @user = User.find(params[:id])
+ respond_to do |format|
+ format.json { render "users/show" }
+ end
+ end
+end
7 fixtures/rails2/app/models/phone_number.rb
View
@@ -0,0 +1,7 @@
+class PhoneNumber < ActiveRecord::Base
+ belongs_to :user
+
+ def formatted
+ "(#{self.area_code}) #{self.prefix}-#{self.suffix}"
+ end
+end
3  fixtures/rails2/app/models/post.rb
View
@@ -0,0 +1,3 @@
+class Post < ActiveRecord::Base
+ belongs_to :user
+end
3  fixtures/rails2/app/models/user.rb
View
@@ -0,0 +1,3 @@
+class User < ActiveRecord::Base
+ has_many :phone_numbers
+end
6 fixtures/rails2/app/views/layouts/application.html.erb
View
@@ -0,0 +1,6 @@
+<head>
+ Not for RABL
+</head>
+<body>
+ Not for RABL
+</body>
3  fixtures/rails2/app/views/posts/date.json.rabl
View
@@ -0,0 +1,3 @@
+code(:day) { |d| d.day }
+code(:hour) { |d| d.hour }
+code(:full) { |d| d.iso8601 }
11 fixtures/rails2/app/views/posts/index.json.rabl
View
@@ -0,0 +1,11 @@
+collection @posts => :articles
+
+extends "posts/show"
+
+node(:created_by_admin, :if => lambda { |p| p.user.is_admin }) do |p|
+ true
+end
+
+child({ :user => :admin }, { :if => lambda { |p| p.user.is_admin }}) do |p|
+ extends "users/show"
+end
16 fixtures/rails2/app/views/posts/show.json.rabl
View
@@ -0,0 +1,16 @@
+object @post
+
+attributes :title, :body
+attributes :created_at => :posted_at
+
+child :user do
+ extends "users/show"
+end
+
+glue :user do
+ attributes :username => :author_name
+end
+
+code(:created_date) do |p|
+ partial("posts/date", :object => p.created_at)
+end
3  fixtures/rails2/app/views/users/index.rabl
View
@@ -0,0 +1,3 @@
+collection @users
+
+extends "users/show"
6 fixtures/rails2/app/views/users/phone_number.rabl
View
@@ -0,0 +1,6 @@
+attributes :prefix, :suffix, :area_code
+attributes :is_primary => :primary
+
+node :formatted do |n|
+ n.formatted
+end
16 fixtures/rails2/app/views/users/show.rabl
View
@@ -0,0 +1,16 @@
+object @user => :person
+
+attributes :username, :email, :location
+attributes :created_at => :registered_at
+
+node :role do |user|
+ user.is_admin ? 'admin' : 'normal'
+end
+
+child :phone_numbers => :pnumbers do
+ extends "users/phone_number"
+end
+
+node :node_numbers do |u|
+ partial("users/phone_number", :object => u.phone_numbers)
+end
129 fixtures/rails2/config/boot.rb
View
@@ -0,0 +1,129 @@
+# Don't change this file!
+# Configure your app in config/environment.rb and config/environments/*.rb
+
+RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
+
+module Rails
+ class << self
+ def boot!
+ unless booted?
+ preinitialize
+ pick_boot.run
+ end
+ end
+
+ def booted?
+ defined? Rails::Initializer
+ end
+
+ def pick_boot
+ (vendor_rails? ? VendorBoot : GemBoot).new
+ end
+
+ def vendor_rails?
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
+ end
+
+ def preinitialize
+ load(preinitializer_path) if File.exist?(preinitializer_path)
+ end
+
+ def preinitializer_path
+ "#{RAILS_ROOT}/config/preinitializer.rb"
+ end
+ end
+
+ class Boot
+ def run
+ load_initializer
+ Rails::Initializer.run(:set_load_path)
+ end
+ end
+
+ class VendorBoot < Boot
+ def load_initializer
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
+ Rails::Initializer.run(:install_gem_spec_stubs)
+ Rails::GemDependency.add_frozen_gem_path
+ end
+ end
+
+ class GemBoot < Boot
+ def load_initializer
+ self.class.load_rubygems
+ load_rails_gem
+ require 'initializer'
+ end
+
+ def load_rails_gem
+ if version = self.class.gem_version
+ gem 'rails', version
+ else
+ gem 'rails'
+ end
+ rescue Gem::LoadError => load_error
+ if load_error.message =~ /Could not find RubyGem rails/
+ STDERR.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
+ exit 1
+ else
+ raise
+ end
+ end
+
+ class << self
+ def rubygems_version
+ Gem::RubyGemsVersion rescue nil
+ end
+
+ def gem_version
+ if defined? RAILS_GEM_VERSION
+ RAILS_GEM_VERSION
+ elsif ENV.include?('RAILS_GEM_VERSION')
+ ENV['RAILS_GEM_VERSION']
+ else
+ parse_gem_version(read_environment_rb)
+ end
+ end
+
+ def load_rubygems
+ min_version = '1.3.2'
+ require 'rubygems'
+ unless rubygems_version >= min_version
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
+ exit 1
+ end
+
+ rescue LoadError
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
+ exit 1
+ end
+
+ def parse_gem_version(text)
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
+ end
+
+ private
+ def read_environment_rb
+ File.read("#{RAILS_ROOT}/config/environment.rb")
+ end
+ end
+ end
+end
+
+# Bundler: http://gembundler.com/rails23.html
+class Rails::Boot
+ def run
+ load_initializer
+
+ Rails::Initializer.class_eval do
+ def load_gems
+ @bundler_loaded ||= Bundler.require :default, Rails.env
+ end
+ end
+
+ Rails::Initializer.run(:set_load_path)
+ end
+end
+
+# All that for this:
+Rails.boot!
16 fixtures/rails2/config/database.yml
View
@@ -0,0 +1,16 @@
+# SQLite version 3.x
+# gem install sqlite3-ruby (not necessary on OS X Leopard)
+development:
+ adapter: sqlite3
+ database: ":memory:"
+ pool: 5
+ timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite3
+ database: ":memory:"
+ pool: 5
+ timeout: 5000
42 fixtures/rails2/config/environment.rb
View
@@ -0,0 +1,42 @@
+# Be sure to restart your server when you modify this file
+
+# Specifies gem version of Rails to use when vendor/rails is not present
+RAILS_GEM_VERSION = '2.3.14' unless defined? RAILS_GEM_VERSION
+
+# Bootstrap the Rails environment, frameworks, and default configuration
+require File.join(File.dirname(__FILE__), 'boot')
+
+Rails::Initializer.run do |config|
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Add additional load paths for your own custom dirs
+ # config.autoload_paths += %W( #{RAILS_ROOT}/extras )
+
+ # Specify gems that this application depends on and have them installed with rake gems:install
+ # config.gem "bj"
+ # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
+ # config.gem "sqlite3-ruby", :lib => "sqlite3"
+ # config.gem "aws-s3", :lib => "aws/s3"
+ config.gem "rack-test", :lib => "rack/test"
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Skip frameworks you're not going to use. To use Rails without a database,
+ # you must remove the Active Record framework.
+ # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
+
+ # Activate observers that should always be running
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names.
+ config.time_zone = 'UTC'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
+ # config.i18n.default_locale = :de
+end
17 fixtures/rails2/config/environments/development.rb
View
@@ -0,0 +1,17 @@
+# Settings specified here will take precedence over those in config/environment.rb
+
+# In the development environment your application's code is reloaded on
+# every request. This slows down response time but is perfect for development
+# since you don't have to restart the webserver when you make code changes.
+config.cache_classes = false
+
+# Log error messages when you accidentally call methods on nil.
+config.whiny_nils = true
+
+# Show full error reports and disable caching
+config.action_controller.consider_all_requests_local = true
+config.action_view.debug_rjs = true
+config.action_controller.perform_caching = false
+
+# Don't care if the mailer can't send
+config.action_mailer.raise_delivery_errors = false
28 fixtures/rails2/config/environments/production.rb
View
@@ -0,0 +1,28 @@
+# Settings specified here will take precedence over those in config/environment.rb
+
+# The production environment is meant for finished, "live" apps.
+# Code is not reloaded between requests
+config.cache_classes = true
+
+# Full error reports are disabled and caching is turned on
+config.action_controller.consider_all_requests_local = false
+config.action_controller.perform_caching = true
+config.action_view.cache_template_loading = true
+
+# See everything in the log (default is :info)
+# config.log_level = :debug
+
+# Use a different logger for distributed setups
+# config.logger = SyslogLogger.new
+
+# Use a different cache store in production
+# config.cache_store = :mem_cache_store
+
+# Enable serving of images, stylesheets, and javascripts from an asset server
+# config.action_controller.asset_host = "http://assets.example.com"
+
+# Disable delivery errors, bad email addresses will be ignored
+# config.action_mailer.raise_delivery_errors = false
+
+# Enable threaded mode
+# config.threadsafe!
28 fixtures/rails2/config/environments/test.rb
View
@@ -0,0 +1,28 @@
+# Settings specified here will take precedence over those in config/environment.rb
+
+# The test environment is used exclusively to run your application's
+# test suite. You never need to work with it otherwise. Remember that
+# your test database is "scratch space" for the test suite and is wiped
+# and recreated between test runs. Don't rely on the data there!
+config.cache_classes = true
+
+# Log error messages when you accidentally call methods on nil.
+config.whiny_nils = true
+
+# Show full error reports and disable caching
+config.action_controller.consider_all_requests_local = true
+config.action_controller.perform_caching = false
+config.action_view.cache_template_loading = true
+
+# Disable request forgery protection in test environment
+config.action_controller.allow_forgery_protection = false
+
+# Tell Action Mailer not to deliver emails to the real world.
+# The :test delivery method accumulates sent emails in the
+# ActionMailer::Base.deliveries array.
+config.action_mailer.delivery_method = :test
+
+# Use SQL instead of Active Record's schema dumper when creating the test database.
+# This is necessary if your schema can't be completely dumped by the schema dumper,
+# like if you have constraints or database-specific column types
+# config.active_record.schema_format = :sql
7 fixtures/rails2/config/initializers/backtrace_silencers.rb
View
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying do debug a problem that might steem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
7 fixtures/rails2/config/initializers/cookie_verification_secret.rb
View
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+ActionController::Base.cookie_verifier_secret = '07d74a7edfe4b5e0cf80f002948a3907a515a0dc6c8fdb2411dc73de8547012acde659641dba5cc31b5a40a09c4fd1298c2ea0080eda689181ed786502e70e00';
10 fixtures/rails2/config/initializers/inflections.rb
View
@@ -0,0 +1,10 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format
+# (all these examples are active by default):
+# ActiveSupport::Inflector.inflections do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
5 fixtures/rails2/config/initializers/mime_types.rb
View
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
+# Mime::Type.register_alias "text/html", :iphone
21 fixtures/rails2/config/initializers/new_rails_defaults.rb
View
@@ -0,0 +1,21 @@
+# Be sure to restart your server when you modify this file.
+
+# These settings change the behavior of Rails 2 apps and will be defaults
+# for Rails 3. You can remove this initializer when Rails 3 is released.
+
+if defined?(ActiveRecord)
+ # Include Active Record class name as root for JSON serialized output.
+ ActiveRecord::Base.include_root_in_json = true
+
+ # Store the full class name (including module namespace) in STI type column.
+ ActiveRecord::Base.store_full_sti_class = true
+end
+
+ActionController::Routing.generate_best_match = false
+
+# Use ISO 8601 format for JSON serialized times and dates.
+ActiveSupport.use_standard_json_time_format = true
+
+# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
+# if you're including raw json in an HTML page.
+ActiveSupport.escape_html_entities_in_json = false
6 fixtures/rails2/config/initializers/rabl_loader.rb
View
@@ -0,0 +1,6 @@
+# Run Migrations
+require 'activerecord'
+dbconf = YAML::load(File.open('config/database.yml'))[Rails.env]
+ActiveRecord::Base.establish_connection(dbconf)
+ActiveRecord::Base.logger = Logger.new(File.open('log/database.log', 'a'))
+ActiveRecord::Migrator.up('db/migrate')
15 fixtures/rails2/config/initializers/session_store.rb
View
@@ -0,0 +1,15 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying cookie session data integrity.
+# If you change this key, all old sessions will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+ActionController::Base.session = {
+ :key => '_rails2_session',
+ :secret => 'b2d31ab1f626a19684aee969cb099d7ab2824150dae712c1c69aaf421bbce2ceb9c2ae85ea9f213440e6baa8e6029f75cebe80fa3af2de8309f885e5f646e8a8'
+}
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rake db:sessions:create")
+# ActionController::Base.session_store = :active_record_store
5 fixtures/rails2/config/locales/en.yml
View
@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+ hello: "Hello world"
20 fixtures/rails2/config/preinitializer.rb
View
@@ -0,0 +1,20 @@
+begin
+ require "rubygems"
+ require "bundler"
+rescue LoadError
+ raise "Could not load the bundler gem. Install it with `gem install bundler`."
+end
+
+if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
+ raise RuntimeError, "Your bundler version is too old for Rails 2.3." +
+ "Run `gem install bundler` to upgrade."
+end
+
+begin
+ # Set up load paths for all bundled gems
+ ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
+ Bundler.setup
+rescue Bundler::GemNotFound
+ raise RuntimeError, "Bundler couldn't find some gems." +
+ "Did you run `bundle install`?"
+end
45 fixtures/rails2/config/routes.rb
View
@@ -0,0 +1,45 @@
+ActionController::Routing::Routes.draw do |map|
+ map.resources :posts
+ map.resources :users
+ # The priority is based upon order of creation: first created -> highest priority.
+
+ # Sample of regular route:
+ # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
+ # Keep in mind you can assign values other than :controller and :action
+
+ # Sample of named route:
+ # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
+ # This route can be invoked with purchase_url(:id => product.id)
+
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
+ # map.resources :products
+
+ # Sample resource route with options:
+ # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
+
+ # Sample resource route with sub-resources:
+ # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
+
+ # Sample resource route with more complex sub-resources
+ # map.resources :products do |products|
+ # products.resources :comments
+ # products.resources :sales, :collection => { :recent => :get }
+ # end
+
+ # Sample resource route within a namespace:
+ # map.namespace :admin do |admin|
+ # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
+ # admin.resources :products
+ # end
+
+ # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
+ # map.root :controller => "welcome"
+
+ # See how all your routes lay out with "rake routes"
+
+ # Install the default routes as the lowest priority.
+ # Note: These default routes make all actions in every controller accessible via GET requests. You should
+ # consider removing or commenting them out if you're using named routes and resources.
+ # map.connect ':controller/:action/:id'
+ # map.connect ':controller/:action/:id.:format'
+end
14 fixtures/rails2/db/migrate/20111002075037_create_posts.rb
View
@@ -0,0 +1,14 @@
+class CreatePosts < ActiveRecord::Migration
+ def self.up
+ create_table :posts do |t|
+ t.integer :user_id
+ t.string :title
+ t.text :body
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :posts
+ end
+end
15 fixtures/rails2/db/migrate/20111002075053_create_users.rb
View
@@ -0,0 +1,15 @@
+class CreateUsers < ActiveRecord::Migration
+ def self.up
+ create_table :users do |t|
+ t.string :username
+ t.string :email
+ t.string :location
+ t.boolean :is_admin
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :users
+ end
+end
16 fixtures/rails2/db/migrate/20111002075112_create_phone_numbers.rb
View
@@ -0,0 +1,16 @@
+class CreatePhoneNumbers < ActiveRecord::Migration
+ def self.up
+ create_table :phone_numbers do |t|
+ t.integer :user_id
+ t.boolean :is_primary
+ t.string :area_code
+ t.string :prefix
+ t.string :suffix
+ t.string :name
+ end
+ end
+
+ def self.down
+ drop_table :phone_numbers
+ end
+end
40 fixtures/rails2/db/schema.rb
View
@@ -0,0 +1,40 @@
+# This file is auto-generated from the current state of the database. Instead of editing this file,
+# please use the migrations feature of Active Record to incrementally modify your database, and
+# then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your database schema. If you need
+# to create the application database on another system, you should be using db:schema:load, not running
+# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20111002075112) do
+
+ create_table "phone_numbers", :force => true do |t|
+ t.integer "user_id"
+ t.boolean "is_primary"
+ t.string "area_code"
+ t.string "prefix"
+ t.string "suffix"
+ t.string "name"
+ end
+
+ create_table "posts", :force => true do |t|
+ t.integer "user_id"
+ t.string "title"
+ t.text "body"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "users", :force => true do |t|
+ t.string "username"
+ t.string "email"
+ t.string "location"
+ t.boolean "is_admin"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+end
7 fixtures/rails2/db/seeds.rb
View
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+#
+# Examples:
+#
+# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
+# Major.create(:name => 'Daley', :city => cities.first)
2  fixtures/rails2/doc/README_FOR_APP
View
@@ -0,0 +1,2 @@
+Use this README file to introduce your application and point to useful places in the API for learning more.
+Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
2,151 fixtures/rails2/log/database.log
View
2,151 additions, 0 deletions not shown
84 fixtures/rails2/log/development.log
View
@@ -0,0 +1,84 @@
+ SQL (0.7ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.1ms) select sqlite_version(*)
+ SQL (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
+ SQL (0.0ms) PRAGMA index_list("schema_migrations")
+ SQL (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
+ SQL (0.1ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.1ms) SELECT version FROM schema_migrations
+ SQL (0.5ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.1ms) select sqlite_version(*)
+ SQL (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
+ SQL (0.0ms) PRAGMA index_list("schema_migrations")
+ SQL (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
+ SQL (0.1ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.0ms) SELECT version FROM schema_migrations
+ SQL (0.5ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.1ms) select sqlite_version(*)
+ SQL (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
+ SQL (0.0ms) PRAGMA index_list("schema_migrations")
+ SQL (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
+ SQL (0.1ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.1ms) SELECT version FROM schema_migrations
+Migrating to CreatePosts (20111002075037)
+ SQL (1.0ms) CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "title" varchar(255), "body" text, "created_at" datetime, "updated_at" datetime) 
+ SQL (0.3ms) INSERT INTO schema_migrations (version) VALUES ('20111002075037')
+Migrating to CreateUsers (20111002075053)
+ SQL (0.4ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(255), "email" varchar(255), "location" varchar(255), "is_admin" boolean, "created_at" datetime, "updated_at" datetime) 
+ SQL (0.1ms) INSERT INTO schema_migrations (version) VALUES ('20111002075053')
+Migrating to CreatePhoneNumbers (20111002075112)
+ SQL (2.1ms) CREATE TABLE "phone_numbers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "is_primary" boolean, "area_code" varchar(255), "prefix" varchar(255), "suffix" varchar(255), "name" varchar(255)) 
+ SQL (0.1ms) INSERT INTO schema_migrations (version) VALUES ('20111002075112')
+ SQL (0.2ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.1ms) SELECT version FROM schema_migrations
+ SQL (0.1ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.0ms) PRAGMA index_list("phone_numbers")
+ SQL (0.0ms) PRAGMA index_list("posts")
+ SQL (0.1ms) PRAGMA index_list("users")
+ SQL (0.6ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.1ms) select sqlite_version(*)
+ SQL (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
+ SQL (0.0ms) PRAGMA index_list("schema_migrations")
+ SQL (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
+ SQL (0.1ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.0ms) SELECT version FROM schema_migrations
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from <top (required)> at /Users/nesquena/.rvm/gems/ruby-1.9.2-p180@testrabl/gems/activerecord-2.3.14/lib/activerecord.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from <top (required)> at /Users/nesquena/.rvm/gems/ruby-1.9.2-p180@testrabl/gems/activerecord-2.3.14/lib/activerecord.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from <top (required)> at /Users/nesquena/.rvm/gems/ruby-1.9.2-p180@testrabl/gems/activerecord-2.3.14/lib/activerecord.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from <top (required)> at /Users/nesquena/.rvm/gems/ruby-1.9.2-p180@testrabl/gems/activerecord-2.3.14/lib/activerecord.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from <top (required)> at /Users/nesquena/.rvm/gems/ruby-1.9.2-p180@testrabl/gems/activerecord-2.3.14/lib/activerecord.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from <top (required)> at /Users/nesquena/.rvm/gems/ruby-1.9.2-p180@testrabl/gems/activerecord-2.3.14/lib/activerecord.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from <top (required)> at /Users/nesquena/.rvm/gems/ruby-1.9.2-p180@testrabl/gems/activerecord-2.3.14/lib/activerecord.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from <top (required)> at /Users/nesquena/.rvm/gems/ruby-1.9.2-p180@testrabl/gems/activerecord-2.3.14/lib/activerecord.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from <top (required)> at /Users/nesquena/.rvm/gems/ruby-1.9.2-p180@testrabl/gems/activerecord-2.3.14/lib/activerecord.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from <top (required)> at /Users/nesquena/.rvm/gems/ruby-1.9.2-p180@testrabl/gems/activerecord-2.3.14/lib/activerecord.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from <top (required)> at /Users/nesquena/.rvm/gems/ruby-1.9.2-p180@testrabl/gems/activerecord-2.3.14/lib/activerecord.rb:2)
0  fixtures/rails2/log/production.log
View
No changes.
0  fixtures/rails2/log/server.log
View
No changes.
327 fixtures/rails2/log/test.log
View
@@ -0,0 +1,327 @@
+
+
+Processing PostsController#/posts (for 0.0.0.0 at 2011-10-02 01:02:56) [GET]
+
+
+Processing PostsController#index (for 127.0.0.1 at 2011-10-02 01:17:24) [GET]
+
+ActionView::MissingTemplate (Missing template posts/index.erb in view path /Users/nesquena/Dropbox/Development/projects/rabl/fixtures/rails2/app/views):
+ <internal:prelude>:10:in `synchronize'
+ /Users/nesquena/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/forwardable.rb:182:in `get'
+ test/functionals/posts_controller_test.rb:17:in `block (3 levels) in <main>'
+ riot (0.12.5) lib/riot/situation.rb:42:in `instance_eval'
+ riot (0.12.5) lib/riot/situation.rb:42:in `setup'
+ riot (0.12.5) lib/riot/runnable.rb:49:in `run'
+ riot (0.12.5) lib/riot/context.rb:101:in `block in local_run'
+ riot (0.12.5) lib/riot/context.rb:101:in `each'
+ riot (0.12.5) lib/riot/context.rb:101:in `local_run'
+ riot (0.12.5) lib/riot/context.rb:91:in `run'
+ riot (0.12.5) lib/riot/context.rb:135:in `block in run_sub_contexts'
+ riot (0.12.5) lib/riot/context.rb:135:in `each'
+ riot (0.12.5) lib/riot/context.rb:135:in `run_sub_contexts'
+ riot (0.12.5) lib/riot/context.rb:92:in `run'
+ riot (0.12.5) lib/riot.rb:39:in `block (2 levels) in run'
+ riot (0.12.5) lib/riot.rb:39:in `each'
+ riot (0.12.5) lib/riot.rb:39:in `block in run'
+ riot (0.12.5) lib/riot/reporter.rb:45:in `summarize'
+ riot (0.12.5) lib/riot.rb:38:in `run'
+ riot (0.12.5) lib/riot.rb:129:in `block in <module:Riot>'
+
+Rendering rescues/layout (internal_server_error)
+
+
+Processing PostsController#index to json (for 127.0.0.1 at 2011-10-02 01:18:17) [GET]
+Rendering posts/index
+
+ActionView::TemplateError (undefined method `user' for #<Post:0x00000101447c38>) on line #2 of app/views/posts/index.json.rabl:
+1: collection @posts => :articles
+2:
+3: extends "posts/show"
+4:
+5: node(:created_by_admin, :if => lambda { |p| p.user.is_admin }) do |p|
+
+ rabl (0.3.0) lib/rabl/helpers.rb:19:in `data_name'
+ rabl (0.3.0) lib/rabl/builder.rb:74:in `child'
+ rabl (0.3.0) lib/rabl/builder.rb:33:in `block in to_hash'
+ rabl (0.3.0) lib/rabl/builder.rb:32:in `each'
+ rabl (0.3.0) lib/rabl/builder.rb:32:in `to_hash'
+ rabl (0.3.0) lib/rabl/engine.rb:37:in `to_hash'
+ rabl (0.3.0) lib/rabl/engine.rb:28:in `render'
+ rabl (0.3.0) lib/rabl/helpers.rb:42:in `object_to_hash'
+ rabl (0.3.0) lib/rabl/helpers.rb:33:in `partial'
+ rabl (0.3.0) lib/rabl/builder.rb:93:in `extends'
+ rabl (0.3.0) lib/rabl/builder.rb:21:in `block in to_hash'
+ rabl (0.3.0) lib/rabl/builder.rb:20:in `each'
+ rabl (0.3.0) lib/rabl/builder.rb:20:in `to_hash'
+ rabl (0.3.0) lib/rabl/engine.rb:40:in `block in to_hash'
+ rabl (0.3.0) lib/rabl/engine.rb:40:in `map'
+ rabl (0.3.0) lib/rabl/engine.rb:40:in `to_hash'
+ rabl (0.3.0) lib/rabl/engine.rb:49:in `to_json'
+ rabl (0.3.0) lib/rabl/engine.rb:28:in `render'
+ app/views/posts/index.json.rabl:2:in `_run_rabl_app47views47posts47index46json46rabl'
+ <internal:prelude>:10:in `synchronize'
+ /Users/nesquena/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/forwardable.rb:182:in `get'
+ test/functionals/posts_controller_test.rb:17:in `block (3 levels) in <main>'
+ riot (0.12.5) lib/riot/situation.rb:42:in `instance_eval'
+ riot (0.12.5) lib/riot/situation.rb:42:in `setup'
+ riot (0.12.5) lib/riot/runnable.rb:49:in `run'
+ riot (0.12.5) lib/riot/context.rb:101:in `block in local_run'
+ riot (0.12.5) lib/riot/context.rb:101:in `each'
+ riot (0.12.5) lib/riot/context.rb:101:in `local_run'
+ riot (0.12.5) lib/riot/context.rb:91:in `run'
+ riot (0.12.5) lib/riot/context.rb:135:in `block in run_sub_contexts'
+ riot (0.12.5) lib/riot/context.rb:135:in `each'
+ riot (0.12.5) lib/riot/context.rb:135:in `run_sub_contexts'
+ riot (0.12.5) lib/riot/context.rb:92:in `run'
+ riot (0.12.5) lib/riot.rb:39:in `block (2 levels) in run'
+ riot (0.12.5) lib/riot.rb:39:in `each'
+ riot (0.12.5) lib/riot.rb:39:in `block in run'
+ riot (0.12.5) lib/riot/reporter.rb:45:in `summarize'
+ riot (0.12.5) lib/riot.rb:38:in `run'
+ riot (0.12.5) lib/riot.rb:129:in `block in <module:Riot>'
+
+Rendered rescues/_trace (61.2ms)
+Rendered rescues/_request_and_response (76.5ms)
+Rendering rescues/layout (internal_server_error)
+
+
+Processing PostsController#index to json (for 127.0.0.1 at 2011-10-02 01:19:29) [GET]
+Rendering posts/index
+Completed in 243ms (View: 240, DB: 5) | 200 OK [http://example.org/posts.json]
+
+
+Processing PostsController#index to json (for 127.0.0.1 at 2011-10-02 01:20:32) [GET]
+Rendering posts/index
+Completed in 111ms (View: 108, DB: 5) | 200 OK [http://example.org/posts.json]
+
+
+Processing PostsController#index (for 127.0.0.1 at 2011-10-02 01:20:50) [GET]
+Rendering template within layouts/application
+Rendering posts/index
+
+ActionView::MissingTemplate (Missing template posts/index.erb in view path /Users/nesquena/Dropbox/Development/projects/rabl/fixtures/rails2/app/views):
+ app/controllers/posts_controller.rb:4:in `index'
+ <internal:prelude>:10:in `synchronize'
+ /Users/nesquena/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/forwardable.rb:182:in `get'
+ test/functionals/posts_controller_test.rb:17:in `block (3 levels) in <main>'
+ riot (0.12.5) lib/riot/situation.rb:42:in `instance_eval'
+ riot (0.12.5) lib/riot/situation.rb:42:in `setup'
+ riot (0.12.5) lib/riot/runnable.rb:49:in `run'
+ riot (0.12.5) lib/riot/context.rb:101:in `block in local_run'
+ riot (0.12.5) lib/riot/context.rb:101:in `each'
+ riot (0.12.5) lib/riot/context.rb:101:in `local_run'
+ riot (0.12.5) lib/riot/context.rb:91:in `run'
+ riot (0.12.5) lib/riot/context.rb:135:in `block in run_sub_contexts'
+ riot (0.12.5) lib/riot/context.rb:135:in `each'
+ riot (0.12.5) lib/riot/context.rb:135:in `run_sub_contexts'
+ riot (0.12.5) lib/riot/context.rb:92:in `run'
+ riot (0.12.5) lib/riot.rb:39:in `block (2 levels) in run'
+ riot (0.12.5) lib/riot.rb:39:in `each'
+ riot (0.12.5) lib/riot.rb:39:in `block in run'
+ riot (0.12.5) lib/riot/reporter.rb:45:in `summarize'
+ riot (0.12.5) lib/riot.rb:38:in `run'
+ riot (0.12.5) lib/riot.rb:129:in `block in <module:Riot>'
+
+Rendering rescues/layout (internal_server_error)
+
+
+Processing PostsController#index (for 127.0.0.1 at 2011-10-02 01:22:43) [GET]
+Rendering posts/index
+Completed in 114ms (View: 111, DB: 6) | 200 OK [http://example.org/posts]
+
+
+Processing PostsController#index (for 127.0.0.1 at 2011-10-02 01:25:52) [GET]
+Rendering posts/index
+Completed in 125ms (View: 122, DB: 6) | 200 OK [http://example.org/posts]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:25:52) [GET]
+ Parameters: {"id"=>"7"}
+Rendering posts/show
+Completed in 8ms (View: 6, DB: 3) | 200 OK [http://example.org/posts/7]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:25:52) [GET]
+ Parameters: {"id"=>"10"}
+Rendering posts/show
+Completed in 6ms (View: 5, DB: 2) | 200 OK [http://example.org/posts/10]
+
+
+Processing PostsController#index (for 127.0.0.1 at 2011-10-02 01:26:48) [GET]
+Rendering posts/index
+Completed in 110ms (View: 107, DB: 5) | 200 OK [http://example.org/posts]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:26:48) [GET]
+ Parameters: {"id"=>"7"}
+Rendering posts/show
+Completed in 13ms (View: 11, DB: 3) | 200 OK [http://example.org/posts/7]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:26:48) [GET]
+ Parameters: {"id"=>"10"}
+Rendering posts/show
+Completed in 11ms (View: 9, DB: 10) | 200 OK [http://example.org/posts/10]
+
+
+Processing PostsController#index (for 127.0.0.1 at 2011-10-02 01:27:38) [GET]
+Rendering posts/index
+Completed in 111ms (View: 107, DB: 6) | 200 OK [http://example.org/posts]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:27:38) [GET]
+ Parameters: {"id"=>"7"}
+Rendering posts/show
+Completed in 8ms (View: 7, DB: 3) | 200 OK [http://example.org/posts/7]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:27:38) [GET]
+ Parameters: {"id"=>"10"}
+Rendering posts/show
+Completed in 7ms (View: 6, DB: 2) | 200 OK [http://example.org/posts/10]
+
+
+Processing PostsController#index (for 127.0.0.1 at 2011-10-02 01:30:34) [GET]
+Rendering posts/index
+Completed in 35ms (View: 31, DB: 6) | 200 OK [http://example.org/posts]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:30:34) [GET]
+ Parameters: {"id"=>"7"}
+Rendering posts/show
+Completed in 7ms (View: 6, DB: 2) | 200 OK [http://example.org/posts/7]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:30:34) [GET]
+ Parameters: {"id"=>"10"}
+Rendering posts/show
+Completed in 7ms (View: 6, DB: 2) | 200 OK [http://example.org/posts/10]
+
+
+Processing PostsController#index (for 127.0.0.1 at 2011-10-02 01:30:52) [GET]
+Rendering posts/index
+Completed in 34ms (View: 31, DB: 5) | 200 OK [http://example.org/posts]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:30:52) [GET]
+ Parameters: {"id"=>"7"}
+Rendering posts/show
+Completed in 12ms (View: 10, DB: 2) | 200 OK [http://example.org/posts/7]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:30:52) [GET]
+ Parameters: {"id"=>"10"}
+Rendering posts/show
+Completed in 9ms (View: 8, DB: 2) | 200 OK [http://example.org/posts/10]
+
+
+Processing PostsController#index (for 127.0.0.1 at 2011-10-02 01:31:03) [GET]
+Rendering posts/index
+Completed in 97ms (View: 93, DB: 6) | 200 OK [http://example.org/posts]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:31:03) [GET]
+ Parameters: {"id"=>"7"}
+Rendering posts/show
+Completed in 7ms (View: 6, DB: 2) | 200 OK [http://example.org/posts/7]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:31:03) [GET]
+ Parameters: {"id"=>"10"}
+Rendering posts/show
+Completed in 7ms (View: 6, DB: 2) | 200 OK [http://example.org/posts/10]
+
+
+Processing UsersController#index (for 127.0.0.1 at 2011-10-02 01:32:08) [GET]
+Rendering users/index
+Completed in 28ms (View: 25, DB: 4) | 200 OK [http://example.org/users]
+
+
+Processing UsersController#show (for 127.0.0.1 at 2011-10-02 01:32:08) [GET]
+ Parameters: {"id"=>"7"}
+Rendering users/show
+Completed in 5ms (View: 4, DB: 1) | 200 OK [http://example.org/users/7]
+
+
+Processing PostsController#index (for 127.0.0.1 at 2011-10-02 01:33:04) [GET]
+Rendering posts/index
+Completed in 75ms (View: 72, DB: 17) | 200 OK [http://example.org/posts]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:33:04) [GET]
+ Parameters: {"id"=>"7"}
+Rendering posts/show
+Completed in 10ms (View: 7, DB: 2) | 200 OK [http://example.org/posts/7]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:33:04) [GET]
+ Parameters: {"id"=>"10"}
+Rendering posts/show
+Completed in 6ms (View: 5, DB: 2) | 200 OK [http://example.org/posts/10]
+
+
+Processing UsersController#index (for 127.0.0.1 at 2011-10-02 01:33:04) [GET]
+Rendering users/index
+Completed in 11ms (View: 9, DB: 2) | 200 OK [http://example.org/users]
+
+
+Processing UsersController#show (for 127.0.0.1 at 2011-10-02 01:33:04) [GET]
+ Parameters: {"id"=>"19"}
+Rendering users/show
+Completed in 5ms (View: 4, DB: 1) | 200 OK [http://example.org/users/19]
+
+
+Processing PostsController#index (for 127.0.0.1 at 2011-10-02 01:34:02) [GET]
+Rendering posts/index
+Completed in 64ms (View: 61, DB: 5) | 200 OK [http://example.org/posts]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:34:02) [GET]
+ Parameters: {"id"=>"7"}
+Rendering posts/show
+Completed in 11ms (View: 9, DB: 2) | 200 OK [http://example.org/posts/7]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:34:02) [GET]
+ Parameters: {"id"=>"10"}
+Rendering posts/show
+Completed in 7ms (View: 6, DB: 3) | 200 OK [http://example.org/posts/10]
+
+
+Processing UsersController#index (for 127.0.0.1 at 2011-10-02 01:34:02) [GET]
+Rendering users/index
+Completed in 11ms (View: 9, DB: 2) | 200 OK [http://example.org/users]
+
+
+Processing UsersController#show (for 127.0.0.1 at 2011-10-02 01:34:02) [GET]
+ Parameters: {"id"=>"19"}
+Rendering users/show
+Completed in 7ms (View: 5, DB: 2) | 200 OK [http://example.org/users/19]
+
+
+Processing PostsController#index (for 127.0.0.1 at 2011-10-02 01:36:02) [GET]
+Rendering posts/index
+Completed in 36ms (View: 33, DB: 5) | 200 OK [http://example.org/posts]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:36:03) [GET]
+ Parameters: {"id"=>"7"}
+Rendering posts/show
+Completed in 8ms (View: 7, DB: 2) | 200 OK [http://example.org/posts/7]
+
+
+Processing PostsController#show (for 127.0.0.1 at 2011-10-02 01:36:03) [GET]
+ Parameters: {"id"=>"10"}
+Rendering posts/show
+Completed in 6ms (View: 5, DB: 2) | 200 OK [http://example.org/posts/10]
+
+
+Processing UsersController#index (for 127.0.0.1 at 2011-10-02 01:36:03) [GET]
+Rendering users/index
+Completed in 20ms (View: 10, DB: 9) | 200 OK [http://example.org/users]
+
+
+Processing UsersController#show (for 127.0.0.1 at 2011-10-02 01:36:03) [GET]
+ Parameters: {"id"=>"19"}
+Rendering users/show
+Completed in 5ms (View: 4, DB: 1) | 200 OK [http://example.org/users/19]
30 fixtures/rails2/public/404.html
View
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+ <title>The page you were looking for doesn't exist (404)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/404.html -->
+ <div class="dialog">
+ <h1>The page you were looking for doesn't exist.</h1>
+ <p>You may have mistyped the address or the page may have moved.</p>
+ </div>
+</body>
+</html>
30 fixtures/rails2/public/422.html
View
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+ <title>The change you wanted was rejected (422)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/422.html -->
+ <div class="dialog">
+ <h1>The change you wanted was rejected.</h1>
+ <p>Maybe you tried to change something you didn't have access to.</p>
+ </div>
+</body>
+</html>
30 fixtures/rails2/public/500.html
View
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+ <title>We're sorry, but something went wrong (500)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/500.html -->
+ <div class="dialog">
+ <h1>We're sorry, but something went wrong.</h1>
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
+ </div>
+</body>
+</html>
0  fixtures/rails2/public/favicon.ico
View
No changes.
BIN  fixtures/rails2/public/images/rails.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
275 fixtures/rails2/public/index.html
View
@@ -0,0 +1,275 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+ <title>Ruby on Rails: Welcome aboard</title>
+ <style type="text/css" media="screen">
+ body {
+ margin: 0;
+ margin-bottom: 25px;
+ padding: 0;
+ background-color: #f0f0f0;
+ font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
+ font-size: 13px;
+ color: #333;
+ }
+
+ h1 {
+ font-size: 28px;
+ color: #000;
+ }
+
+ a {color: #03c}
+ a:hover {
+ background-color: #03c;
+ color: white;
+ text-decoration: none;
+ }
+
+
+ #page {
+ background-color: #f0f0f0;
+ width: 750px;
+ margin: 0;
+ margin-left: auto;
+ margin-right: auto;
+ }
+
+ #content {
+ float: left;
+ background-color: white;
+ border: 3px solid #aaa;
+ border-top: none;
+ padding: 25px;
+ width: 500px;
+ }
+
+ #sidebar {
+ float: right;
+ width: 175px;
+ }
+
+ #footer {
+ clear: both;
+ }
+
+
+ #header, #about, #getting-started {
+ padding-left: 75px;
+ padding-right: 30px;
+ }
+
+
+ #header {
+ background-image: url("images/rails.png");
+ background-repeat: no-repeat;
+ background-position: top left;
+ height: 64px;
+ }
+ #header h1, #header h2 {margin: 0}
+ #header h2 {
+ color: #888;
+ font-weight: normal;
+ font-size: 16px;
+ }
+
+
+ #about h3 {
+ margin: 0;
+ margin-bottom: 10px;
+ font-size: 14px;
+ }
+
+ #about-content {
+ background-color: #ffd;
+ border: 1px solid #fc0;
+ margin-left: -11px;
+ }
+ #about-content table {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ font-size: 11px;
+ border-collapse: collapse;
+ }
+ #about-content td {
+ padding: 10px;
+ padding-top: 3px;
+ padding-bottom: 3px;
+ }
+ #about-content td.name {color: #555}
+ #about-content td.value {color: #000}
+
+ #about-content.failure {
+ background-color: #fcc;
+ border: 1px solid #f00;
+ }
+ #about-content.failure p {
+ margin: 0;
+ padding: 10px;
+ }
+
+
+ #getting-started {
+ border-top: 1px solid #ccc;
+ margin-top: 25px;
+ padding-top: 15px;
+ }
+ #getting-started h1 {
+ margin: 0;
+ font-size: 20px;
+ }
+ #getting-started h2 {
+ margin: 0;
+ font-size: 14px;
+ font-weight: normal;
+ color: #333;
+ margin-bottom: 25px;
+ }
+ #getting-started ol {
+ margin-left: 0;
+ padding-left: 0;
+ }
+ #getting-started li {
+ font-size: 18px;
+ color: #888;
+ margin-bottom: 25px;
+ }
+ #getting-started li h2 {
+ margin: 0;
+ font-weight: normal;
+ font-size: 18px;
+ color: #333;
+ }
+ #getting-started li p {
+ color: #555;
+ font-size: 13px;
+ }
+
+
+ #search {
+ margin: 0;
+ padding-top: 10px;
+ padding-bottom: 10px;
+ font-size: 11px;
+ }
+ #search input {
+ font-size: 11px;
+ margin: 2px;
+ }
+ #search-text {width: 170px}
+
+
+ #sidebar ul {
+ margin-left: 0;
+ padding-left: 0;
+ }
+ #sidebar ul h3 {
+ margin-top: 25px;
+ font-size: 16px;
+ padding-bottom: 10px;
+ border-bottom: 1px solid #ccc;
+ }
+ #sidebar li {
+ list-style-type: none;
+ }
+ #sidebar ul.links li {
+ margin-bottom: 5px;
+ }
+
+ </style>
+ <script type="text/javascript" src="javascripts/prototype.js"></script>
+ <script type="text/javascript" src="javascripts/effects.js"></script>
+ <script type="text/javascript">
+ function about() {
+ if (Element.empty('about-content')) {
+ new Ajax.Updater('about-content', 'rails/info/properties', {
+ method: 'get',
+ onFailure: function() {Element.classNames('about-content').add('failure')},
+ onComplete: function() {new Effect.BlindDown('about-content', {duration: 0.25})}
+ });
+ } else {
+ new Effect[Element.visible('about-content') ?
+ 'BlindUp' : 'BlindDown']('about-content', {duration: 0.25});
+ }
+ }
+
+ window.onload = function() {
+ $('search-text').value = '';
+ $('search').onsubmit = function() {
+ $('search-text').value = 'site:rubyonrails.org ' + $F('search-text');
+ }
+ }
+ </script>
+ </head>
+ <body>
+ <div id="page">
+ <div id="sidebar">
+ <ul id="sidebar-items">
+ <li>
+ <form id="search" action="http://www.google.com/search" method="get">
+ <input type="hidden" name="hl" value="en" />
+ <input type="text" id="search-text" name="q" value="site:rubyonrails.org " />
+ <input type="submit" value="Search" /> the Rails site
+ </form>
+ </li>
+
+ <li>
+ <h3>Join the community</h3>
+ <ul class="links">
+ <li><a href="http://www.rubyonrails.org/">Ruby on Rails</a></li>
+ <li><a href="http://weblog.rubyonrails.org/">Official weblog</a></li>
+ <li><a href="http://wiki.rubyonrails.org/">Wiki</a></li>
+ </ul>
+ </li>
+
+ <li>
+ <h3>Browse the documentation</h3>
+ <ul class="links">
+ <li><a href="http://api.rubyonrails.org/">Rails API</a></li>
+ <li><a href="http://stdlib.rubyonrails.org/">Ruby standard library</a></li>
+ <li><a href="http://corelib.rubyonrails.org/">Ruby core</a></li>
+ <li><a href="http://guides.rubyonrails.org/">Rails Guides</a></li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+
+ <div id="content">
+ <div id="header">
+ <h1>Welcome aboard</h1>
+ <h2>You&rsquo;re riding Ruby on Rails!</h2>
+ </div>
+
+ <div id="about">
+ <h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
+ <div id="about-content" style="display: none"></div>
+ </div>
+
+ <div id="getting-started">
+ <h1>Getting started</h1>
+ <h2>Here&rsquo;s how to get rolling:</h2>
+
+ <ol>
+ <li>
+ <h2>Use <tt>script/generate</tt> to create your models and controllers</h2>
+ <p>To see all available options, run it without parameters.</p>
+ </li>
+
+ <li>
+ <h2>Set up a default route and remove or rename this file</h2>
+ <p>Routes are set up in config/routes.rb.</p>
+ </li>
+
+ <li>
+ <h2>Create your database</h2>
+ <p>Run <tt>rake db:migrate</tt> to create your database. If you're not using SQLite (the default), edit <tt>config/database.yml</tt> with your username and password.</p>
+ </li>
+ </ol>
+ </div>
+ </div>
+
+ <div id="footer">&nbsp;</div>
+ </div>
+ </body>
+</html>
2  fixtures/rails2/public/javascripts/application.js
View
@@ -0,0 +1,2 @@
+// Place your application-specific JavaScript functions and classes here
+// This file is automatically included by javascript_include_tag :defaults
963 fixtures/rails2/public/javascripts/controls.js
View
@@ -0,0 +1,963 @@
+// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005-2008 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
+// (c) 2005-2008 Jon Tirsen (http://www.tirsen.com)
+// Contributors:
+// Richard Livsey
+// Rahul Bhargava
+// Rob Wills
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+// Autocompleter.Base handles all the autocompletion functionality
+// that's independent of the data source for autocompletion. This
+// includes drawing the autocompletion menu, observing keyboard
+// and mouse events, and similar.
+//
+// Specific autocompleters need to provide, at the very least,
+// a getUpdatedChoices function that will be invoked every time
+// the text inside the monitored textbox changes. This method
+// should get the text for which to provide autocompletion by
+// invoking this.getToken(), NOT by directly accessing
+// this.element.value. This is to allow incremental tokenized
+// autocompletion. Specific auto-completion logic (AJAX, etc)
+// belongs in getUpdatedChoices.
+//
+// Tokenized incremental autocompletion is enabled automatically
+// when an autocompleter is instantiated with the 'tokens' option
+// in the options parameter, e.g.:
+// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' });
+// will incrementally autocomplete with a comma as the token.
+// Additionally, ',' in the above example can be replaced with
+// a token array, e.g. { tokens: [',', '\n'] } which
+// enables autocompletion on multiple tokens. This is most
+// useful when one of the tokens is \n (a newline), as it
+// allows smart autocompletion after linebreaks.
+
+if(typeof Effect == 'undefined')
+ throw("controls.js requires including script.aculo.us' effects.js library");
+
+var Autocompleter = { };
+Autocompleter.Base = Class.create({
+ baseInitialize: function(element, update, options) {
+ element = $(element);
+ this.element = element;
+ this.update = $(update);
+ this.hasFocus = false;
+ this.changed = false;
+ this.active = false;
+ this.index = 0;
+ this.entryCount = 0;
+ this.oldElementValue = this.element.value;
+
+ if(this.setOptions)
+ this.setOptions(options);
+ else
+ this.options = options || { };
+
+ this.options.paramName = this.options.paramName || this.element.name;
+ this.options.tokens = this.options.tokens || [];
+ this.options.frequency = this.options.frequency || 0.4;
+ this.options.minChars = this.options.minChars || 1;
+ this.options.onShow = this.options.onShow ||
+ function(element, update){
+ if(!update.style.position || update.style.position=='absolute') {
+ update.style.position = 'absolute';
+ Position.clone(element, update, {
+ setHeight: false,
+ offsetTop: element.offsetHeight
+ });
+ }
+ Effect.Appear(update,{duration:0.15});
+ };
+ this.options.onHide = this.options.onHide ||
+ function(element, update){ new Effect.Fade(update,{duration:0.15}) };
+
+ if(typeof(this.options.tokens) == 'string')
+ this.options.tokens = new Array(this.options.tokens);
+ // Force carriage returns as token delimiters anyway
+ if (!this.options.tokens.include('\n'))
+ this.options.tokens.push('\n');
+
+ this.observer = null;
+
+ this.element.setAttribute('autocomplete','off');
+
+ Element.hide(this.update);
+
+ Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));
+ Event.observe(this.element, 'keydown', this.onKeyPress.bindAsEventListener(this));
+ },
+
+ show: function() {
+ if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
+ if(!this.iefix &&
+ (Prototype.Browser.IE) &&
+ (Element.getStyle(this.update, 'position')=='absolute')) {
+ new Insertion.After(this.update,
+ '<iframe id="' + this.update.id + '_iefix" '+
+ 'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
+ 'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
+ this.iefix = $(this.update.id+'_iefix');
+ }
+ if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
+ },
+
+ fixIEOverlapping: function() {
+ Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
+ this.iefix.style.zIndex = 1;
+ this.update.style.zIndex = 2;
+ Element.show(this.iefix);
+ },
+
+ hide: function() {
+ this.stopIndicator();
+ if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);
+ if(this.iefix) Element.hide(this.iefix);
+ },
+
+ startIndicator: function() {
+ if(this.options.indicator) Element.show(this.options.indicator);
+ },
+
+ stopIndicator: function() {
+ if(this.options.indicator) Element.hide(this.options.indicator);
+ },
+
+ onKeyPress: function(event) {
+ if(this.active)
+ switch(event.keyCode) {
+ case Event.KEY_TAB:
+ case Event.KEY_RETURN:
+ this.selectEntry();
+ Event.stop(event);
+ case Event.KEY_ESC:
+ this.hide();
+ this.active = false;
+ Event.stop(event);
+ return;
+ case Event.KEY_LEFT:
+ case Event.KEY_RIGHT:
+ return;
+ case Event.KEY_UP:
+ this.markPrevious();
+ this.render();
+ Event.stop(event);
+ return;
+ case Event.KEY_DOWN:
+ this.markNext();
+ this.render();
+ Event.stop(event);
+ return;
+ }
+ else
+ if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
+ (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
+
+ this.changed = true;
+ this.hasFocus = true;
+
+ if(this.observer) clearTimeout(this.observer);
+ this.observer =
+ setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
+ },
+
+ activate: function() {
+ this.changed = false;
+ this.hasFocus = true;
+ this.getUpdatedChoices();
+ },
+
+ onHover: function(event) {
+ var element = Event.findElement(event, 'LI');
+ if(this.index != element.autocompleteIndex)
+ {
+ this.index = element.autocompleteIndex;
+ this.render();
+ }
+ Event.stop(event);
+ },
+
+ onClick: function(event) {
+ var element = Event.findElement(event, 'LI');
+ this.index = element.autocompleteIndex;
+ this.selectEntry();
+ this.hide();
+ },
+
+ onBlur: function(event) {
+ // needed to make click events working
+ setTimeout(this.hide.bind(this), 250);
+ this.hasFocus = false;
+ this.active = false;
+ },
+
+ render: function() {
+ if(this.entryCount > 0) {
+ for (var i = 0; i < this.entryCount; i++)
+ this.index==i ?
+ Element.addClassName(this.getEntry(i),"selected") :
+ Element.removeClassName(this.getEntry(i),"selected");
+ if(this.hasFocus) {
+ this.show();
+ this.active = true;
+ }
+ } else {
+ this.active = false;
+ this.hide();
+ }
+ },
+
+ markPrevious: function() {
+ if(this.index > 0) this.index--;
+ else this.index = this.entryCount-1;
+ this.getEntry(this.index).scrollIntoView(true);
+ },
+
+ markNext: function() {
+ if(this.index < this.entryCount-1) this.index++;
+ else this.index = 0;
+ this.getEntry(this.index).scrollIntoView(false);
+ },
+
+ getEntry: function(index) {
+ return this.update.firstChild.childNodes[index];
+ },
+
+ getCurrentEntry: function() {
+ return this.getEntry(this.index);
+ },
+
+ selectEntry: function() {
+ this.active = false;
+ this.updateElement(this.getCurrentEntry());
+ },
+
+ updateElement: function(selectedElement) {
+ if (this.options.updateElement) {
+ this.options.updateElement(selectedElement);
+ return;
+ }
+ var value = '';
+ if (this.options.select) {
+ var nodes = $(selectedElement).select('.' + this.options.select) || [];
+ if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
+ } else
+ value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
+
+ var bounds = this.getTokenBounds();
+ if (bounds[0] != -1) {
+ var newValue = this.element.value.substr(0, bounds[0]);
+ var whitespace = this.element.value.substr(bounds[0]).match(/^\s+/);
+ if (whitespace)
+ newValue += whitespace[0];
+ this.element.value = newValue + value + this.element.value.substr(bounds[1]);
+ } else {
+ this.element.value = value;
+ }
+ this.oldElementValue = this.element.value;
+ this.element.focus();
+
+ if (this.options.afterUpdateElement)
+ this.options.afterUpdateElement(this.element, selectedElement);
+ },
+
+ updateChoices: function(choices) {
+ if(!this.changed && this.hasFocus) {
+ this.update.innerHTML = choices;
+ Element.cleanWhitespace(this.update);
+ Element.cleanWhitespace(this.update.down());
+
+ if(this.update.firstChild && this.update.down().childNodes) {
+ this.entryCount =
+ this.update.down().childNodes.length;
+ for (var i = 0; i < this.entryCount; i++) {
+ var entry = this.getEntry(i);
+ entry.autocompleteIndex = i;
+ this.addObservers(entry);
+ }
+ } else {
+ this.entryCount = 0;
+ }
+
+ this.stopIndicator();
+ this.index = 0;
+
+ if(this.entryCount==1 && this.options.autoSelect) {
+ this.selectEntry();
+ this.hide();
+ } else {
+ this.render();
+ }
+ }
+ },
+
+ addObservers: function(element) {
+ Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));
+ Event.observe(element, "click", this.onClick.bindAsEventListener(this));
+ },
+
+ onObserverEvent: function() {
+ this.changed = false;
+ this.tokenBounds = null;
+ if(this.getToken().length>=this.options.minChars) {
+ this.getUpdatedChoices();
+ } else {
+ this.active = false;
+ this.hide();
+ }
+ this.oldElementValue = this.element.value;
+ },
+
+ getToken: function() {
+ var bounds = this.getTokenBounds();
+ return this.element.value.substring(bounds[0], bounds[1]).strip();
+ },
+
+ getTokenBounds: function() {
+ if (null != this.tokenBounds) return this.tokenBounds;
+ var value = this.element.value;
+ if (value.strip().empty()) return [-1, 0];
+ var diff = arguments.callee.getFirstDifferencePos(value, this.oldElementValue);
+ var offset = (diff == this.oldElementValue.length ? 1 : 0);
+ var prevTokenPos = -1, nextTokenPos = value.length;
+ var tp;
+ for (var index = 0, l = this.options.tokens.length; index < l; ++index) {
+ tp = value.lastIndexOf(this.options.tokens[index], diff + offset - 1);
+ if (tp > prevTokenPos) prevTokenPos = tp;
+ tp = value.indexOf(this.options.tokens[index], diff + offset);
+ if (-1 != tp && tp < nextTokenPos) nextTokenPos = tp;
+ }
+ return (this.tokenBounds = [prevTokenPos + 1, nextTokenPos]);
+ }
+});
+
+Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) {
+ var boundary = Math.min(newS.length, oldS.length);
+ for (var index = 0; index < boundary; ++index)
+ if (newS[index] != oldS[index])
+ return index;
+ return boundary;
+};
+
+Ajax.Autocompleter = Class.create(Autocompleter.Base, {
+ initialize: function(element, update, url, options) {
+ this.baseInitialize(element, update, options);
+ this.options.asynchronous = true;
+ this.options.onComplete = this.onComplete.bind(this);
+ this.options.defaultParams = this.options.parameters || null;
+ this.url = url;
+ },
+
+ getUpdatedChoices: function() {
+ this.startIndicator();
+
+ var entry = encodeURIComponent(this.options.paramName) + '=' +
+ encodeURIComponent(this.getToken());
+
+ this.options.parameters = this.options.callback ?
+ this.options.callback(this.element, entry) : entry;
+
+ if(this.options.defaultParams)
+ this.options.parameters += '&' + this.options.defaultParams;
+
+ new Ajax.Request(this.url, this.options);
+ },
+
+ onComplete: function(request) {
+ this.updateChoices(request.responseText);
+ }
+});
+
+// The local array autocompleter. Used when you'd prefer to
+// inject an array of autocompletion options into the page, rather
+// than sending out Ajax queries, which can be quite slow sometimes.
+//
+// The constructor takes four parameters. The first two are, as usual,
+// the id of the monitored textbox, and id of the autocompletion menu.
+// The third is the array you want to autocomplete from, and the fourth
+// is the options block.
+//
+// Extra local autocompletion options:
+// - choices - How many autocompletion choices to offer
+//
+// - partialSearch - If false, the autocompleter will match entered
+// text only at the beginning of strings in the
+// autocomplete array. Defaults to true, which will
+// match text at the beginning of any *word* in the
+// strings in the autocomplete array. If you want to
+// search anywhere in the string, additionally set
+// the option fullSearch to true (default: off).
+//
+// - fullSsearch - Search anywhere in autocomplete array strings.
+//
+// - partialChars - How many characters to enter before triggering
+// a partial match (unlike minChars, which defines
+// how many characters are required to do any match
+// at all). Defaults to 2.
+//
+// - ignoreCase - Whether to ignore case when autocompleting.
+// Defaults to true.
+//
+// It's possible to pass in a custom function as the 'selector'
+// option, if you prefer to write your own autocompletion logic.
+// In that case, the other options above will not apply unless
+// you support them.
+
+Autocompleter.Local = Class.create(Autocompleter.Base, {
+ initialize: function(element, update, array, options) {
+ this.baseInitialize(element, update, options);
+ this.options.array = array;
+ },
+
+ getUpdatedChoices: function() {
+ this.updateChoices(this.options.selector(this));
+ },
+
+ setOptions: function(options) {
+ this.options = Object.extend({
+ choices: 10,
+ partialSearch: true,
+ partialChars: 2,
+ ignoreCase: true,
+ fullSearch: false,
+ selector: function(instance) {
+ var ret = []; // Beginning matches
+ var partial = []; // Inside matches
+ var entry = instance.getToken();
+ var count = 0;
+
+ for (var i = 0; i < instance.options.array.length &&
+ ret.length < instance.options.choices ; i++) {
+
+ var elem = instance.options.array[i];
+ var foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase()) :
+ elem.indexOf(entry);
+
+ while (foundPos != -1) {
+ if (foundPos == 0 && elem.length != entry.length) {
+ ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
+ elem.substr(entry.length) + "</li>");
+ break;
+ } else if (entry.length >= instance.options.partialChars &&
+ instance.options.partialSearch && foundPos != -1) {
+ if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
+ partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
+ elem.substr(foundPos, entry.length) + "</strong>" + elem.substr(
+ foundPos + entry.length) + "</li>");
+ break;
+ }
+ }
+
+ foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
+ elem.indexOf(entry, foundPos + 1);
+
+ }
+ }
+ if (partial.length)
+ ret = ret.concat(partial.slice(0, instance.options.choices - ret.length));
+ return "<ul>" + ret.join('') + "</ul>";
+ }
+ }, options || { });
+ }
+});
+
+// AJAX in-place editor and collection editor
+// Full rewrite by Christophe Porteneuve <tdd@tddsworld.com> (April 2007).
+
+// Use this if you notice weird scrolling problems on some browsers,
+// the DOM might be a bit confused when this gets called so do this
+// waits 1 ms (with setTimeout) until it does the activation
+Field.scrollFreeActivate = function(field) {
+ setTimeout(function() {
+ Field.activate(field);
+ }, 1);
+};
+
+Ajax.InPlaceEditor = Class.create({
+ initialize: function(element, url, options) {
+ this.url = url;
+ this.element = element = $(element);
+ this.prepareOptions();
+ this._controls = { };
+ arguments.callee.dealWithDeprecatedOptions(options); // DEPRECATION LAYER!!!
+ Object.extend(this.options, options || { });
+ if (!this.options.formId && this.element.id) {
+ this.options.formId = this.element.id + '-inplaceeditor';
+ if ($(this.options.formId))
+ this.options.formId = '';
+ }
+ if (this.options.externalControl)
+ this.options.externalControl = $(this.options.externalControl);
+ if (!this.options.externalControl)
+ this.options.externalControlOnly = false;
+ this._originalBackground = this.element.getStyle('background-color') || 'transparent';
+ this.element.title = this.options.clickToEditText;
+ this._boundCancelHandler = this.handleFormCancellation.bind(this);
+ this._boundComplete = (this.options.onComplete || Prototype.emptyFunction).bind(this);
+ this._boundFailureHandler = this.handleAJAXFailure.bind(this);
+ this._boundSubmitHandler = this.handleFormSubmission.bind(this);
+ this._boundWrapperHandler = this.wrapUp.bind(this);
+ this.registerListeners();
+ },
+ checkForEscapeOrReturn: function(e) {
+ if (!this._editing || e.ctrlKey || e.altKey || e.shiftKey) return;
+ if (Event.KEY_ESC == e.keyCode)
+ this.handleFormCancellation(e);
+ else if (Event.KEY_RETURN == e.keyCode)
+ this.handleFormSubmission(e);
+ },
+ createControl: function(mode, handler, extraClasses) {
+ var control = this.options[mode + 'Control'];
+ var text = this.options[mode + 'Text'];
+ if ('button' == control) {
+ var btn = document.createElement('input');
+ btn.type = 'submit';
+ btn.value = text;
+ btn.className = 'editor_' + mode + '_button';
+ if ('cancel' == mode)
+ btn.onclick = this._boundCancelHandler;
+ this._form.appendChild(btn);
+ this._controls[mode] = btn;
+ } else if ('link' == control) {
+ var link = document.createElement('a');
+ link.href = '#';
+ link.appendChild(document.createTextNode(text));
+ link.onclick = 'cancel' == mode ? this._boundCancelHandler : this._boundSubmitHandler;
+ link.className = 'editor_' + mode + '_link';
+ if (extraClasses)
+ link.className += ' ' + extraClasses;
+ this._form.appendChild(link);
+ this._controls[mode] = link;
+ }
+ },
+ createEditField: function() {
+ var text = (this.options.loadTextURL ? this.options.loadingText : this.getText());
+ var fld;
+ if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) {
+ fld = document.createElement('input');
+ fld.type = 'text';
+ var size = this.options.size || this.options.cols || 0;
+ if (0 < size) fld.size = size;
+ } else {
+ fld = document.createElement('textarea');
+ fld.rows = (1 >= this.options.rows ? this.options.autoRows : this.options.rows);
+ fld.cols = this.options.cols || 40;
+ }
+ fld.name = this.options.paramName;
+ fld.value = text; // No HTML breaks conversion anymore
+ fld.className = 'editor_field';
+ if (this.options.submitOnBlur)
+ fld.onblur = this._boundSubmitHandler;
+ this._controls.editor = fld;
+ if (this.options.loadTextURL)
+ this.loadExternalText();
+ this._form.appendChild(this._controls.editor);
+ },
+ createForm: function() {
+ var ipe = this;
+ function addText(mode, condition) {
+ var text = ipe.options['text' + mode + 'Controls'];
+ if (!text || condition === false) return;
+ ipe._form.appendChild(document.createTextNode(text));
+ };
+ this._form = $(document.createElement('form'));
+ this._form.id = this.options.formId;
+ this._form.addClassName(this.options.formClassName);
+ this._form.onsubmit = this._boundSubmitHandler;
+ this.createEditField();
+ if ('textarea' == this._controls.editor.tagName.toLowerCase())
+ this._form.appendChild(document.createElement('br'));
+ if (this.options.onFormCustomization)
+ this.options.onFormCustomization(this, this._form);
+ addText('Before', this.options.okControl || this.options.cancelControl);
+ this.createControl('ok', this._boundSubmitHandler);
+ addText('Between', this.options.okControl && this.options.cancelControl);
+ this.createControl('cancel', this._boundCancelHandler, 'editor_cancel');
+ addText('After', this.options.okControl || this.options.cancelControl);
+ },
+ destroy: function() {
+ if (this._oldInnerHTML)
+ this.element.innerHTML = this._oldInnerHTML;
+ this.leaveEditMode();
+ this.unregisterListeners();
+ },
+ enterEditMode: function(e) {
+ if (this._saving || this._editing) return;
+ this._editing = true;
+ this.triggerCallback('onEnterEditMode');
+ if (this.options.externalControl)
+ this.options.externalControl.hide();
+ this.element.hide();
+ this.createForm();
+ this.element.parentNode.insertBefore(this._form, this.element);
+ if (!this.options.loadTextURL)
+ this.postProcessEditField();
+ if (e) Event.stop(e);
+ },
+ enterHover: function(e) {
+ if (this.options.hoverClassName)
+ this.element.addClassName(this.options.hoverClassName);
+ if (this._saving) return;
+ this.triggerCallback('onEnterHover');
+ },
+ getText: function() {
+ return this.element.innerHTML.unescapeHTML();
+ },
+ handleAJAXFailure: function(transport) {
+ this.triggerCallback('onFailure', transport);
+ if (this._oldInnerHTML) {
+ this.element.innerHTML = this._oldInnerHTML;
+ this._oldInnerHTML = null;
+ }
+ },
+ handleFormCancellation: function(e) {
+ this.wrapUp();
+ if (e) Event.stop(e);
+ },
+ handleFormSubmission: function(e) {
+ var form = this._form;
+ var value = $F(this._controls.editor);
+ this.prepareSubmission();
+ var params = this.options.callback(form, value) || '';
+ if (Object.isString(params))
+ params = params.toQueryParams();
+ params.editorId = this.element.id;
+ if (this.options.htmlResponse) {
+ var options = Object.extend({ evalScripts: true }, this.options.ajaxOptions);
+ Object.extend(options, {
+ parameters: params,
+ onComplete: this._boundWrapperHandler,
+ onFailure: this._boundFailureHandler
+ });
+ new Ajax.Updater({ success: this.element }, this.url, options);
+ } else {
+ var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
+ Object.extend(options, {
+ parameters: params,
+ onComplete: this._boundWrapperHandler,
+ onFailure: this._boundFailureHandler
+ });
+ new Ajax.Request(this.url, options);
+ }
+ if (e) Event.stop(e);
+ },
+ leaveEditMode: function() {
+ this.element.removeClassName(this.options.savingClassName);
+ this.removeForm();
+ this.leaveHover();
+ this.element.style.backgroundColor = this._originalBackground;
+ this.element.show();
+ if (this.options.externalControl)
+ this.options.externalControl.show();
+ this._saving = false;
+ this._editing = false;
+ this._oldInnerHTML = null;
+ this.triggerCallback('onLeaveEditMode');
+ },
+ leaveHover: function(e) {
+ if (this.options.hoverClassName)
+ this.element.removeClassName(this.options.hoverClassName);
+ if (this._saving) return;
+ this.triggerCallback('onLeaveHover');
+ },
+ loadExternalText: function() {
+ this._form.addClassName(this.options.loadingClassName);
+ this._controls.editor.disabled = true;
+ var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
+ Object.extend(options, {
+ parameters: 'editorId=' + encodeURIComponent(this.element.id),
+ onComplete: Prototype.emptyFunction,
+ onSuccess: function(transport) {
+ this._form.removeClassName(this.options.loadingClassName);
+ var text = transport.responseText;
+ if (this.options.stripLoadedTextTags)
+ text = text.stripTags();
+ this._controls.editor.value = text;
+ this._controls.editor.disabled = false;
+ this.postProcessEditField();
+ }.bind(this),
+ onFailure: this._boundFailureHandler
+ });
+ new Ajax.Request(this.options.loadTextURL, options);
+ },
+ postProcessEditField: function() {
+ var fpc = this.options.fieldPostCreation;
+ if (fpc)
+ $(this._controls.editor)['focus' == fpc ? 'focus' : 'activate']();
+ },
+ prepareOptions: function() {
+ this.options = Object.clone(Ajax.InPlaceEditor.DefaultOptions);
+ Object.extend(this.options, Ajax.InPlaceEditor.DefaultCallbacks);
+ [this._extraDefaultOptions].flatten().compact().each(function(defs) {
+ Object.extend(this.options, defs);
+ }.bind(this));
+ },
+ prepareSubmission: function() {
+ this._saving = true;
+ this.removeForm();
+ this.leaveHover();
+ this.showSaving();
+ },
+ registerListeners: function() {
+ this._listeners = { };
+ var listener;
+ $H(Ajax.InPlaceEditor.Listeners).each(function(pair) {
+ listener = this[pair.value].bind(this);
+ this._listeners[pair.key] = listener;
+ if (!this.options.externalControlOnly)
+ this.element.observe(pair.key, listener);
+ if (this.options.externalControl)
+ this.options.externalControl.observe(pair.key, listener);
+ }.bind(this));
+ },
+ removeForm: function() {
+ if (!this._form) return;
+ this._form.remove();
+ this._form = null;
+ this._controls = { };
+ },
+ showSaving: function() {
+ this._oldInnerHTML = this.element.innerHTML;
+ this.element.innerHTML = this.options.savingText;
+ this.element.addClassName(this.options.savingClassName);
+ this.element.style.backgroundColor = this._originalBackground;
+ this.element.show();
+ },
+ triggerCallback: function(cbName, arg) {
+ if ('function' == typeof this.options[cbName]) {
+ this.options[cbName](this, arg);
+ }
+ },
+ unregisterListeners: function() {
+ $H(this._listeners).each(function(pair) {
+ if (!this.options.externalControlOnly)
+ this.element.stopObserving(pair.key, pair.value);
+ if (this.options.externalControl)
+ this.options.externalControl.stopObserving(pair.key, pair.value);
+ }.bind(this));
+ },
+ wrapUp: function(transport) {
+ this.leaveEditMode();
+ // Can't use triggerCallback due to backward compatibility: requires
+ // binding + direct element
+ this._boundComplete(transport, this.element);
+ }
+});
+
+Object.extend(Ajax.InPlaceEditor.prototype, {
+ dispose: Ajax.InPlaceEditor.prototype.destroy
+});
+
+Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, {
+ initialize: function($super, element, url, options) {
+ this._extraDefaultOptions = Ajax.InPlaceCollectionEditor.DefaultOptions;
+ $super(element, url, options);
+ },
+
+ createEditField: function() {
+ var list = document.createElement('select');
+ list.name = this.options.paramName;
+ list.size = 1;
+ this._controls.editor = list;
+ this._collection = this.options.collection || [];
+ if (this.options.loadCollectionURL)
+ this.loadCollection();
+ else
+ this.checkForExternalText();
+ this._form.appendChild(this._controls.editor);
+ },
+
+ loadCollection: function() {
+ this._form.addClassName(this.options.loadingClassName);
+ this.showLoadingText(this.options.loadingCollectionText);
+ var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
+ Object.extend(options, {
+ parameters: 'editorId=' + encodeURIComponent(this.element.id),
+ onComplete: Prototype.emptyFunction,
+ onSuccess: function(transport) {
+ var js = transport.responseText.strip();
+ if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check
+ throw('Server returned an invalid collection representation.');
+ this._collection = eval(js);
+ this.checkForExternalText();
+ }.bind(this),
+ onFailure: this.onFailure
+ });
+ new Ajax.Request(this.options.loadCollectionURL, options);
+ },
+
+ showLoadingText: function(text) {
+ this._controls.editor.disabled = true;
+ var tempOption = this._controls.editor.firstChild;
+ if (!tempOption) {
+ tempOption = document.createElement('option');
+ tempOption.value = '';
+ this._controls.editor.appendChild(tempOption);
+ tempOption.selected = true;
+ }
+ tempOption.update((text || '').stripScripts().stripTags());
+ },
+
+ checkForExternalText: function() {
+ this._text = this.getText();
+ if (this.options.loadTextURL)
+ this.loadExternalText();